WebBrowser自动填表问题请教

lililaoj 2007-01-21 01:13:31
上次发控件区了,没人解答,我再发一次希望有人帮忙:
下面这个表单"确认密码"用webbrowser应当怎么自动输入
帐户密码:<input name="userpwd" type="hidden" value="" id="userpwd"><input name="text" type="text" class="txtstyle" onBlur="getpass(this,'userpwd')" onKeyUp="getpass(this,'userpwd')" value="" size="24" maxlength="15" autocomplete="off" class="txtstyle" /></td>
确认密码:<input name="reuserpwd" type="hidden" value="" id="reuserpwd"><input name="text" type="text" class="txtstyle" onBlur="getpass(this,'reuserpwd')" onKeyUp="getpass(this,'reuserpwd')" value="" size="24" maxlength="15" autocomplete="off" class="txtstyle" /></td>
根据name的值不成,只能根据后面的input,可是上面和下面的怎么区分,谢谢各位
现在第一个我可以用:w1.Document.getElementById("text").Value = "要写的内容"
填上,第二个实在没办法填了!
...全文
643 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Ulick 2007-03-05
  • 打赏
  • 举报
回复
呵呵,自己写几行HTML就行了哦,在FROM中,ACTION指向那个站。

偶就见过一个这么BT的,写:<input name="userpwd" maxlength="5">。。。。。。

也没有在服务器上加个SESSION,偶用上面的方法,50个字也写进去了。
crxwz 2007-02-02
  • 打赏
  • 举报
回复
楼上的太麻烦了:我说一下我的方法:

With WebBrowser1.Document
.All("userpwd") = "" '密码
.All("text").Item(0) = "" '第1个text
.All("reuserpwd") = "" '确认密码
.All("text").Item(1) = "" '第2个text
End With

注:上面的代码没什么扩展性,主要是说明一下引用元素的方式。
我写过一个表单内容本地化保存的子程序,那要复杂一点,但比较通用
lililaoj 2007-01-22
  • 打赏
  • 举报
回复
谢谢二楼的已经按你的办法解决,又学到了一些东西!
wang2oo8 2007-01-21
  • 打赏
  • 举报
回复
Dim vDoc, vTag
Dim i As Integer
Set vDoc = WebBrowser1.Document
For i = 0 To vDoc.All.length - 1 '检测所有标签
Set vTag = vDoc.All(i)
Select Case vTag.tagname
Case "INPUT" '这里注意大写
Select Case vTag.name
Case "username"
vTag.Value = Text1.Text
Case "text"
vTag.Value = "你想要的内容"

end select
end select
next

用你的那段代码测试成功!^_^
清晨曦月 2007-01-21
  • 打赏
  • 举报
回复
可以用名引用,,..我BLOG上有

1,502

社区成员

发帖
与我相关
我的任务
社区描述
VB 网络编程
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧