I'm having trouble getting the syntax right to select an item from a dropdown on a webpage. It's to select gender. I think it's something to do with it using javascript. When I do Inspect element on the dropdown I get the following:
When I do the same on a dropdown item I get:
I've tried various formats in my code but none seem to work. Any help would be much appreciated.
Code:
<table width="100%" style="z-index: auto;" cellspacing="0" cellpadding="0" oldz="auto">
<tbody style="z-index: auto;" oldz="auto"><tr style="z-index: auto;" oldz="auto">
<td style="width: 100%; z-index: auto;" oldz="auto">
<div class="FBox" style="width: auto; position: relative; z-index: auto;" oldz="auto" outerdiv="Y">
<input name="VX_Gender" id="VX_Gender" type="hidden" value="M">
<div class="EditDiv EditDropDown" id="VX_Gender_ext" role="textbox" contenteditable="true" spellcheck="false" ondrop="return false" origval="Male" hig="1" max="-1" strictselection="Y" focstyle="EditDropDownFoc" isfilter="Y" filterbox="Y" val2="Male" LastTouchType="Y">Male</div>
********>initDiv('VX_Gender');*********>
</div>
</td>
<td style="white-space: nowrap;"></td>
</tr>
</tbody>
</table>
When I do the same on a dropdown item I get:
Code:
<div class="filtermenu" style="left: 271.76px; top: 252.5px; width: 122px; height: auto; margin-top: 0px; display: none; z-index: 1698; -ms-overflow-y: auto; max-height: 67px;" *******="return filterPopupClick( event );" hovermenu="Y" shrink="Y" unselectable="on" lastfilter="Male">
<div class="bcrow rsel" ***********="return fRowHov(this);" value="F" origva="Female" hc="#FFFFFF" fkey="F" frow="Y" fIdx="2">
Fe
<span class="fsr">male</span>
</div>
<div class="bcrow" ***********="return fRowHov(this);" value="I" origva="Indeterminate" hc="#FFFFFF" fkey="I" frow="Y" fIdx="-1">Indeterminate</div>
<div class="bcrow" ***********="return fRowHov(this);" value="M" origva="Male" hc="#FFFFFF" fkey="M" frow="Y" fIdx="0"><span class="fsr">Male</span></div>
<div class="bcrow" ***********="return fRowHov(this);" value="U" origva="Unborn" hc="#FFFFFF" fkey="U" frow="Y" fIdx="-1">Unborn</div>
</div>
I've tried various formats in my code but none seem to work. Any help would be much appreciated.
Code:
Sub gender()
Dim URL, PER_ID As String
Dim objShell, ie As Object
Dim ele As IHTMLElement
'Determine if a specific instance of IE is already open.
Set objShell = CreateObject("Shell.Application")
IE_count = objShell.Windows.Count
For x = 0 To (IE_count - 1)
On Error Resume Next 'Sometimes more web pages are counted than are open
URL = objShell.Windows(x).******************
If URL = "[URL]https://protocolshef.syhapp.com:51020/web/faorc.htm[/URL]" Then 'Identify the existing web page
Set ie = objShell.Windows(x)
Exit For
Else
End If
Next
For Each ele In ie.document.getElementsByTagName("div")
If ele.ID = "VX_Gender_ext" Then
ele.innerText = "Female"
ele.Val2 = "Female"
Call ie.document.parentWindow.execScript("initDiv('VX_Gender');", "JavaScript")
End If
Next
For Each ele In ie.document.getElementsByName("VX_Gender")
ele.Value = "F"
ele.origval = "F"
Next
For Each ele In ie.document.getElementsByTagName("div")
If ele.ID = "VX_Gender_ext" Then
ele.innerText = "Female"
ele.Val2 = "Female"
Call ie.document.parentWindow.execScript("initDiv('VX_Gender');", "JavaScript")
End If
Next
For Each ele In ie.document.getElementsByName("VX_Gender")
ele.Type = "text"
ele.Value = "F"
ele.origval = "F"
Next
End Sub