Consulting

Results 1 to 1 of 1

Thread: Internet Form with Dropdown List using Java/Ajax

  1. #1

    Internet Form with Dropdown List using Java/Ajax

    How do you select something from a dropdown list that uses Java & maybe Ajax & there’s no <SELECT> in the source? I'm able to populate the input box with the exact info from the dropdown list but because I don't click it in the dropdown list, I get the message "Unable to retrieve employee info".

    Done manually, Step 1 is that I start entering an employee ID and a dropdown list appears that will shorten as I enter more of the employee ID. Then I click the name in the dropdown list and the information will move into the input box. Finally, I click on the submit button which opens a Step 2.

    I should mention:
    1) Clicking the employee in the dropdown list activates a java command called "onclick" which seems to be the equivalent of hitting "enter" and moving the name into the input box.
    2) There’s some Ajax code that uses the same id as my input box (ctl00_ContentPlaceHolder1_txtEmpSearch). Not sure what this does, maybe it’s what opens Step2.
    3) The dropdown list doesn't seem to come from a <SELECT> list.

    Attached is the abbreviated source from an internal network internet form and below is the code I'm using to populate the input box.

    [vba]
    Sub ePAF2()
    Dim i As Long
    Dim objIE As Object
    Dim objElement As Object
    Dim objCollection As Object


    Set objIE = CreateObject("InternetExplorer.Application")
    objIE.Visible = True
    objIE.navigate "https://www03/ePAF/PAF.aspx?Mode=New"

    Do While objIE.Busy
    DoEvents
    Loop


    'INPUT EMPLOYEE INFO
    Set objCollection = objIE.Document.getElementsByTagName("input") 'forms(0) not necessary b/c there's only one form, works with or without
    i = 0
    While i < objCollection.Length
    If objCollection(i).Name = "ctl00$ContentPlaceHolder1$txtEmpSearch" Then
    objCollection(i).Select
    objCollection(i).Value = "123456 - Smith, John)"

    End If
    i = i + 1
    Wend


    'CLICK SUBMIT
    Set objCollection = objIE.Document.getElementsByTagName("input")
    i = 0
    While i < objCollection.Length
    If objCollection(i).Type = "submit" And objCollection(i).Name = "ctl00$ContentPlaceHolder1$btnSearchEmployee" Then
    Set objElement = objCollection(i) ' "Search" button is found
    End If
    i = i + 1
    Wend


    ' Clean up
    Set objIE = Nothing
    Set objElement = Nothing
    Set objCollection = Nothing
    End Sub
    [/vba]
    Attached Files Attached Files

Posting Permissions

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