Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Internet explorer 使用VBScript从Internet Explorer页面的下拉列表中选择项目_Internet Explorer_Vbscript - Fatal编程技术网

Internet explorer 使用VBScript从Internet Explorer页面的下拉列表中选择项目

Internet explorer 使用VBScript从Internet Explorer页面的下拉列表中选择项目,internet-explorer,vbscript,Internet Explorer,Vbscript,我试图打开一个URL并从下拉列表中选择值,然后提交表单,但我无法从下拉列表中选择值 这是我当前的代码: Dim vb Dim ie Set vb = CreateObject("WScript.Shell") Set ie = CreateObject("InternetExplorer.Application") 'start IE ie.Visible = True ie.Navigate "https://www.nseindia.com/live_market/dynaConten

我试图打开一个URL并从下拉列表中选择值,然后提交表单,但我无法从下拉列表中选择值

这是我当前的代码:

Dim vb
Dim ie

Set vb = CreateObject("WScript.Shell")
Set ie = CreateObject("InternetExplorer.Application")

'start IE
ie.Visible = True
ie.Navigate "https://www.nseindia.com/live_market/dynaContent/live_watch/equities_stock_watch.htm"

'Loop until page load
Do While ie.Busy
    WScript.Sleep 200
Loop
WScript.Sleep 200

'Activate ie windows
vb.AppActivate ("NSE - National Stock Exchange of India Ltd. - Internet Explorer")
WScript.Sleep 200

'Now i want to select from dropdown, How can i select option from dropdown list.

'Submit the form
ie.Document.All.Item("dataform").Submit

Set vb = Nothing
Set ie = Nothing

通常,您会循环浏览所有选项并选择所需的选项:

For Each objOption In ie.Document.getElementById("bankNiftySelect").Options

    With objOption
        If .Value = "foSec" Then
            .Selected = True
        Else
            .Selected = False
        End If
    End With

Next

通常,您会循环浏览所有选项并选择所需的选项:

For Each objOption In ie.Document.getElementById("bankNiftySelect").Options

    With objOption
        If .Value = "foSec" Then
            .Selected = True
        Else
            .Selected = False
        End If
    End With

Next

您还可以尝试使用以下代码:

        For Each objOption In IE.Document.getElementById("bankNiftySelect").getElementsByTagName("option")
            With objOption
                If .Value = "foSec" Then
                    .Selected = True
                Else
                    .Selected = False
                End If
            End With
        Next

您还可以尝试使用以下代码:

        For Each objOption In IE.Document.getElementById("bankNiftySelect").getElementsByTagName("option")
            With objOption
                If .Value = "foSec" Then
                    .Selected = True
                Else
                    .Selected = False
                End If
            End With
        Next

谢谢先生,当我们从下拉列表中更改选择时,站点页面会相应更新,但当我们从下拉列表中选择时,使用此过程站点页面不会更新。谢谢先生,当我们从下拉列表中更改选择时,站点页面会相应更新,但当我们从下拉列表中选择时,使用此过程站点页面不会更新。谢谢先生,当我们更改下拉列表中的选择时,站点页面会相应地更新,但当我们使用此过程从下拉列表中选择时,站点页面不会更新。先生,实际上我找到了-ie.Document.getElementById(“bankNiftySelect”)。selectedIndex=38 ie.Document.getElementById(“bankNiftySelect”)。FireEvent(“onchange”)谢谢先生,当我们更改下拉列表中的选择时,站点页面会相应更新,但当我们使用此过程站点页面从下拉列表中选择时,站点页面不会更新。先生,实际上我找到了-ie.Document.getElementById(“bankNiftySelect”)。selectedIndex=38 ie.Document.getElementById(“bankNiftySelect”).FireEvent(“onchange”)