VB自动填表问题80分求解
自动填写下面的表单标题栏:<inputname="subject"id="subject"class="txt"value=""tabindex="1"/></span>...
自动填写下面的表单
标题栏:<input name="subject" id="subject" class="txt" value="" tabindex="1" /></span>
内容栏:<textarea class="autosave max" name="message" id="e_textarea" tabindex="1" class="txt" style="height:300px"></textarea>
提交按钮:<button type="submit" id="postsubmit" value="true" name="topicsubmit" tabindex="1">
提交</button>
请哪位高手给出完整代码谢谢 最好加上注释 展开
标题栏:<input name="subject" id="subject" class="txt" value="" tabindex="1" /></span>
内容栏:<textarea class="autosave max" name="message" id="e_textarea" tabindex="1" class="txt" style="height:300px"></textarea>
提交按钮:<button type="submit" id="postsubmit" value="true" name="topicsubmit" tabindex="1">
提交</button>
请哪位高手给出完整代码谢谢 最好加上注释 展开
5个回答
展开全部
引用Microsoft HTML Object Library
代码:
Option Explicit
Private Sub Command1_Click()
Dim doc As MSHTML.HTMLDocument
Set doc = WebBrowser1.document
Dim inpute As MSHTML.IHTMLInputElement
Set inpute = doc.getElementById("subject")
inpute.Value = "这是要填的subject"
Dim e As MSHTML.IHTMLElement
Set e = doc.getElementById("e_textarea")
e.Value = "message"
Set e = doc.getElementById("postsubmit")
e.Click
End Sub
Private Sub Form_Load()
WebBrowser1.navigate "h:\1.html"
End Sub
'以下是1.html的内容
'<html><body>
'<input name="subject" id="subject" class="txt" value="" tabindex="1" />
'<textarea class="autosave max" name="message" id="e_textarea" tabindex="1" class="txt" style="height:50px"></textarea>
'<button type="submit" id="postsubmit" value="true" name="topicsubmit" tabindex="1" onclick="javascript:alert(1);">提交</button>
'</body></html>
'by xsoft [http://281131020.qzone.qq.com]
'要自动填写的话,加入下列代码:
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If (pDisp Is WebBrowser1.Object) Then
Command1.Value = True
End If
End Sub
代码:
Option Explicit
Private Sub Command1_Click()
Dim doc As MSHTML.HTMLDocument
Set doc = WebBrowser1.document
Dim inpute As MSHTML.IHTMLInputElement
Set inpute = doc.getElementById("subject")
inpute.Value = "这是要填的subject"
Dim e As MSHTML.IHTMLElement
Set e = doc.getElementById("e_textarea")
e.Value = "message"
Set e = doc.getElementById("postsubmit")
e.Click
End Sub
Private Sub Form_Load()
WebBrowser1.navigate "h:\1.html"
End Sub
'以下是1.html的内容
'<html><body>
'<input name="subject" id="subject" class="txt" value="" tabindex="1" />
'<textarea class="autosave max" name="message" id="e_textarea" tabindex="1" class="txt" style="height:50px"></textarea>
'<button type="submit" id="postsubmit" value="true" name="topicsubmit" tabindex="1" onclick="javascript:alert(1);">提交</button>
'</body></html>
'by xsoft [http://281131020.qzone.qq.com]
'要自动填写的话,加入下列代码:
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If (pDisp Is WebBrowser1.Object) Then
Command1.Value = True
End If
End Sub
展开全部
在你上面的表单代码之后加上那个这段代码,页面加载后,表单就会被填充你指定的内容
<script language="javascript">
document.getElementById("subject").value="自定义主题";
document.getElementById("e_textarea").innerText="自定义内容";
</script>
<script language="javascript">
document.getElementById("subject").value="自定义主题";
document.getElementById("e_textarea").innerText="自定义内容";
</script>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
把网页发出来看看
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
把网址发上来,才行的呀。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
网址发上来
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询