Results 1 to 8 of 8

Thread: [RESOLVED] Select list item?

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2005
    Posts
    50

    Resolved [RESOLVED] Select list item?

    Apologize for the cross post but, I think this issue should fall here.

    Please see attached HTML file for source code:

    On the webpage, there is a option called "MANAGE ANALYTICS" that I want to click on first, then a drop down list appears and I want to select "Export File" to take me to the next page. However, the HTMLtag.click is failing. (No errors though, it just doesn't work) Anyone see what I am doing wrong?

    Thanks,
    J

    VB Code:
    1. For i = 0 To WebBrowser.Document.frames.length - 1
    2.                 For Each HTMLtag In WebBrowser.Document.frames(i).Document.All
    3.                     Select Case HTMLtag.tagName
    4.                         Case "SELECT"
    5.                             If HTMLtag.getAttribute("name") = "Admin" Then
    6.                                 For v = 0 To HTMLtag.children.length - 1
    7.                                     If Trim(HTMLtag.children(v).innerText) = Trim("MANAGE ANALYTICS") Then
    8.                                         HTMLtag.Click
    9.                                             If Trim(HTMLtag.children(v).innerText) = Trim("Export File") Then
    10.                                                 HTMLtag.Click
    11.                                             End If
    12.                                     End If
    13.                                 Next
    14.                             End If
    15.                     End Select
    16.                 Next
    17.         Next
    Attached Files Attached Files

  2. #2
    Frenzied Member
    Join Date
    Aug 2005
    Posts
    1,042

    Re: Select list item?

    dolomite:

    I don't know if this helps, but when I ran your code in Internet Explorer I get the following error:

    Error Line 25:
    Parent.Picklistpanel.Location is null or not an object.

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2005
    Posts
    50

    Re: Select list item?

    Hmmm - I do not receive that error. In fact, I do not receive an error at all. From what I have found so far, I need to somehow set "something".selected = True rather than using HTMLtag.Click.

    Any ideas?

  4. #4
    Frenzied Member
    Join Date
    Aug 2005
    Posts
    1,042

    Re: Select list item?

    dolomite:

    It appears that you are using Java Script and I don't know a lot about Java Script.

    However, from the error I got it appears that when you click on Export File it executes line 25 which is: parent.PickListPanel.location.href = URL; and above that you have:
    var URL = form.options[form.selectedIndex].value; which is the value of the index of the selected form. But it doesn't appear that you have anything in your If statement after parent.PickListPanel.location.href = URL that is related to Export File.

    I really don't know, but I think your problem is in the way you are trying to reference the link you wnat to go to when Export File is clicked.

    Why can't you just write an HTML link tag for each item in the drop-down menu?
    Or use somethin like this:

    Dropdown Menu:--------------------------------------------------------------

    <HTML>

    <HEAD>

    <TITLE>Dropdown Menu</TITLE>

    <SCRIPT LANGUAGE="JavaScript">


    function formHandler(form){
    var URL = document.form.site.options[document.form.site.selectedIndex].value;
    window.location.href = URL;
    }

    </SCRIPT>

    </HEAD>

    <BODY>

    <center>
    <form name="form">
    <select name="site" size=1 onChange="javascript:formHandler()">
    <option value="">Go to....
    <option value="http://www.yahoo.com">Yahoo
    <option value="http://www.metacrawler.com">Metacrawler
    <option value="http://www.altavista.digital.com">Altavista
    <option value="http://www.webcrawler.com">Webcrawler
    <option value="http://www.lycos.com">Lycos
    <option value="http://javascript.internet.com">JavaScript Source
    </select>
    </form>
    </center>



    </BODY>

    </HTML>
    ------------------------------------------------------------------------------

    This probably doesn't help a lot, but like I said, I am not a Java Script Expert.

    Good Luck

  5. #5
    Frenzied Member
    Join Date
    Aug 2005
    Posts
    1,042

    Re: Select list item?

    dolomite:

    I just noticed in your original posting you have a For/Next loop in visual Basic. However in the code in your attached file (Text.txt) you are using Java Script.

    Maybe I am confused about what you are trying to do?????

  6. #6

    Thread Starter
    Member
    Join Date
    Aug 2005
    Posts
    50

    Re: Select list item?

    Hi AIS4U -

    I am trying to interact with this webpage through VB. The reason why I attached the HTML source code of this page was to aid in any debugging. From my understanding of the WebBrowser Control, I can use the HTML in the page to call events like a Click event. I'm in the same boat, I do not know too mucj about this either.

    Cheers

  7. #7
    Frenzied Member
    Join Date
    Aug 2005
    Posts
    1,042

    Re: Select list item?

    dolomite:

    Maybe you would have better luck if you posted this in the Classic Visual Basic forum or maybe you already had it there since you stated: "apologize for the cross post ... "

    Sorry I couldn't help much, but good luck.

  8. #8

    Thread Starter
    Member
    Join Date
    Aug 2005
    Posts
    50

    [RESOLVED]: Select list item?

    Got it to work using this:

    VB Code:
    1. Set selectElem = WebBrowser.Document.getElementsByTagName("SELECT")
    2.         For i = 0 To selectElem.length - 1
    3.             If selectElem(i).Name = "Admin" Then
    4.                 For v = 0 To selectElem(i).Options.length - 1
    5.                     Set opt = selectElem(i).Options(v)
    6.                     If opt.Text = "Export File" Then
    7.                         opt.Selected = True
    8.                     End If
    9.                 Next v
    10.             End If
    11.         Next i

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width