webbrowse自动提交表单时select标签怎么给省,市赋值 http://www.yesfashion.cn/register.aspx,谢谢

qxstock 2007-12-02 12:54:31
WebBrowser1.Document.getElementsByName("ddlState").Item(0).selectedIndex = 1
WebBrowser1.Document.getElementsByName("ddlState").Item(0).onchange
WebBrowser1.Document.getElementsByName("ddlProvince").Item(0).selectedIndex = 1


现在能给国家赋值,省县不知到怎么做了
...全文
118 点赞 收藏 13
写回复
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
qxstock 2007-12-22
谢谢,代码感谢提供
回复
qxstock 2007-12-22
谢谢了,思路和代码都谢谢了
回复
zzyong00 2007-12-09
呵呵 早知道就不给你写哪么多代码了,只说个思路就行了
回复
qxstock 2007-12-09
感谢阿勇提供的延时的思路,谢谢
回复
zzyong00 2007-12-03
当程序运行时,无须你做任何事!我用了个command,只是在调试时用的!实际上,command_click中的代码完全可以放在。。。
ElseIf n = 2 Then
。。。
End If
回复
zzyong00 2007-12-03
以上代码测试通过
回复
zzyong00 2007-12-03
当你选完 ddlState时,网页动态从服务器上取得ddlProvince的内容,所以,在选择ddlProvince之前,必须先得延时等待!
Option Explicit
Dim n As Integer
Private Sub Command1_Click()
Dim objSel As HTMLSelectElement, objDoc As HTMLDocument, objCol As IHTMLElementCollection
Set objDoc = WebBrowser1.Document
Set objCol = objDoc.getElementsByName("ddlState")
Set objSel = objCol.Item(0)
'objSel.Value = objSel.Options(1).Value
objSel.selectedIndex = 1
objSel.FireEvent "onchange" 'ddlState
Dim t As Long
t = Timer
Do
DoEvents
Set objCol = objDoc.getElementsByName("ddlProvince")
Set objSel = objCol.Item(0)
Loop While objSel.Options.length <= 1

'objSel.Value = objSel.Options(1).Value
objSel.selectedIndex = 5
objSel.FireEvent "onchange" 'ddlProvince

Do
DoEvents
Set objCol = objDoc.getElementsByName("ddlCity")
Set objSel = objCol.Item(0)
Loop While objSel.Options.length <= 1
'objSel.Value = objSel.Options(1).Value
objSel.selectedIndex = 9
objSel.FireEvent "onchange" 'ddlCity

End Sub

Private Sub Form_Load()
WebBrowser1.Navigate "http://www.yesfashion.cn/register.aspx"
End Sub

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
n = n + 1
If n = 1 Then
Dim objImg As HTMLImg, objDoc As HTMLDocument, objCol As IHTMLElementCollection
Set objDoc = WebBrowser1.Document
Set objCol = objDoc.getElementsByName("ibtnAgree")
Set objImg = objCol.Item(0)
objImg.Click
ElseIf n = 2 Then
Command1_Click
End If
End Sub



回复
qxstock 2007-12-03
地址是 http://www.yesfashion.cn/register.aspx

回复
daisy8675 2007-12-02
http://www.applevb.com/qa/qa000250.htm
http://www.applevb.com/qa/qa000257.htm

用 webbrowse去自提并不好,如果对方有弹出框就根本没办法处理嘛

所以一般情况最好直接抓包,post数据出去
回复
蒋晟 2007-12-02
Item(0)是做什么的
ddlState和ddlProvince估计是IHTMLSelectElement,直接设置其value不行么
回复
zzyong00 2007-12-02
最好引用 Microsoft html object ,哪样容易些
Dim objSel As HTMLSelectElement, objDoc As HTMLDocument, objCol As IHTMLElementCollection
Set objDoc = WebBrowser1.Document
Set objCol = objDoc.getElementsByName("ddlState")
Set objSel = objCol.Item(0)
'objSel.Value = objSel.Options(1).Value
objSel.selectedIndex = 1
objSel.FireEvent "onchange"
.....
回复
zzyong00 2007-12-02
WebBrowser1.Document.getElementsByName("ddlState").Item(0).selectedIndex   =   1     
WebBrowser1.Document.getElementsByName("ddlState").Item(0).FireEvent "onchange"
WebBrowser1.Document.getElementsByName("ddlProvince").Item(0).selectedIndex = 1
回复
zzyong00 2007-12-02
一般来说,选择一个select控件中的一项后,在这个select的onchang事件中会改写其它的select中的项,
哪么你选择一个select,然后调用它的onchang,然后适当地延时,后再去选择其它的select

你给的网址,我打不开
回复
发动态
发帖子
VB基础类
创建于2007-09-28

7451

社区成员

VB 基础类
申请成为版主
社区公告
暂无公告