Reputation: 11
I am trying to navigate through a from in internet explorer via Excel VBA.
This is the VBA code I use to do it, which works fine:
IEDoc.getElementById("PROGRAMME-select").selectedindex = 1
However, for another dropdown menu, which after a selection dynamically changes the rest of the form, the code from above doesn't work. I assume it's due to the javascript of the webpage. This is the HTML code of it:
<DIV id=Q_FORMAT jQuery1441195683481="347">
<INPUT id=Q_FORMAT_data value='{"name":"FORMAT","inputType":"select"}' type=hidden name=Q_FORMAT_data>
<DIV style="DISPLAY: block" id=FORMAT-label>
<LABEL><B>Format :</B> </LABEL></DIV><SELECT id=FORMAT-select name=FORMAT-select>
<OPTION id=FORMAT_EMPTY_OPTION value=EMPTY_OPTION></OPTION>
<OPTION id=FORMAT_YES value=FORMAT_YES name="FORMAT_YES">Non-Standard</OPTION>
<OPTION id=FORMAT_NO selected value=FORMAT_NO name="FORMAT_NO">Standard</OPTION></SELECT> </DIV>
Does anyone know how to trigger the javascript in order to have the rest of the form be updated by the selection I am trying to do? Or possibly it's a completely different issue I am facing here?
Upvotes: 1
Views: 1066
Reputation: 1198
After the form changes it has new html on the document. Instead of using IEDoc - which you probably set before the change - just use ie.document.getElementById("NEW NAME HERE").selectedindex = 1
(This assumes that you set your instance of msie to ie. Just use whatever variable you gave to this instance and .document will always give you the most recent version after any javascript changes. The form ID's might have changed also so you might try listing all ID's in the form again just to see.)
Upvotes: 0
Reputation: 234
can you try using the fireevent method for the listbox and try once ?
eg code:
IEDoc.getElementById("PROGRAMME-select").selectedindex = 2
IEDoc.getElementById("PROGRAMME-select").fireevent "Onchange"
Upvotes: 1