I'm using VBA to automate IE. I have two dropdown lists (let's call them "A" and "B"). The B list depends on the values of the A list, so the B list won't show its values unless I select the A list value manually first. I tried with this:
Sub pifa ()
Dim ie As Object
Set ie = CreateObject("internetexplorer.application")
With ie
.Visible = True
.navigate "https://serviciosjava2.pifa.gob/rcel/jsp/index_bis.jsp"
Do While .Busy
DoEvents
Loop
Do While .readyState <> 4
DoEvents
Loop
ie.document.getElementById("puntodeventa").Value = "31" 'A list value
Do While .Busy
DoEvents
Loop
Do While .readyState <> 4
DoEvents
Loop
ie.document.getElementById("universocomprobante").Value = "19" 'B list value (doesn't work)
End with
End sub
For the A list value everything is OK, it changes the dropdown list value correctly, but as I didn't actually clicked manually the value, the B list won't update and show the values. I also tried this, and doesn't work:
ie.document.getElementById("puntodeventa").Click 'A list value
"A" list code:
<select name="puntoDeVenta" onchange="actualizarDescripcionPVConDelay(this.selectedIndex);ajaxFunction();" id="puntodeventa">
<option value="" selected="selected" style="color:#888;" onclick=document.getElementById("desc_pto_vta").innerHTML="";>seleccionar...</option>
<option value="31"> puntodeventaseleccionado</option>
</select>
"B" list code:
<select name="universoComprobante" onchange="actualizarDescripcionTC(this.selectedIndex);" id="universocomprobante">
<option value="" selected="selected" style="color:#888;">seleccionar...</option>
<option value="10">Factura A</option> 'this appears when I click manually the A list
<option value="19">Factura B</option> 'this appears when I click manually the A list
</select>
I solved it by adding this below the value entrance:
ie.document.getElementById("puntodeventa").FireEvent ("onchange")