Is there anybody here who is familiar with AJAX code through the web browser and VBA coding?
I have a webpage in which there is a pull-down menu for "Request Type." When you pull-down and select an entry from the first pull-down menu, this triggers code to show the second pull-down menu. When you pull-down and select an entry from the second pull-down menu, this triggers code to show a third pull-down menu. What I am looking to achieve is to trigger the code that shows the next pull-down menu in succession, as using the .selectedIndex itself, while it sets the value for that pull-down menu box, it doesn't trigger a change event to trigger showing the next DIV and pull-down menu.
This website uses AJAX to function and while I'm not expert at AJAX I believe this line of code, which directly follows the select tag, is what updates the container and shows the next select pull-down menu.
Here is the entire subset of tr and td tags for the select box. The select tag itself doesn't call any JavaScript or other code, that I can see.
(There's probably a preferred method for posting HTML code in this forum. In the mean time I have replaced the pointy brackets with a curvy bracket to sidestep any display, code execution issues).
Here is my VBA code that I am using to manipulate this code. Previously I was side-stepping the problem by selecting the value above the one that I wanted, giving focus to that control and using send key to send a down arrow to this field to select the next item in the list. Because Internet Explorer saw this as a change to the select box, the AJAX code would trigger.
The problem with that technique (which is really a dirty work-around) is two-fold. 1.) It doesn't always fire correctly due to timing and that jettisons the rest of the code because certain containers and other controls are unhidden based on the value of these pull-down menus. 2.) Starting this morning this technique isn't working correctly on the parent control. I can step through my code and the code is correctly identifying and giving focus to that select tag, but the send key down is no longer working to select the next item in the list.
What I'd love to do is to select the correct item from the select box and then call directly the code that updates and shows the next select pull-down menu.
I have a webpage in which there is a pull-down menu for "Request Type." When you pull-down and select an entry from the first pull-down menu, this triggers code to show the second pull-down menu. When you pull-down and select an entry from the second pull-down menu, this triggers code to show a third pull-down menu. What I am looking to achieve is to trigger the code that shows the next pull-down menu in succession, as using the .selectedIndex itself, while it sets the value for that pull-down menu box, it doesn't trigger a change event to trigger showing the next DIV and pull-down menu.
This website uses AJAX to function and while I'm not expert at AJAX I believe this line of code, which directly follows the select tag, is what updates the container and shows the next select pull-down menu.
Code:
[script]ASB.observeDescendentFields('NewDetailsPanelDiv', 'ticketRequestTypeObserverDiv', null, false, null, {onSuccess:function(e) { CustomFieldsUpdateContainerUpdate() }, _asbn:'7.21.0.0.0.0.2.3.0.0.1.2.0.3.0.1.5.5.0.1.3.1.1.0.0.1.16.11.2.1.3.25.1.1.0'});[/script]
Here is the entire subset of tr and td tags for the select box. The select tag itself doesn't call any JavaScript or other code, that I can see.
Code:
{script}ASB.observeDescendentFields('NewDetailsPanelDiv', 'ticketRequestTypeObserverDiv', null, false, null, {onSuccess:function(e) { CustomFieldsUpdateContainerUpdate() }, _asbn:'7.21.0.0.0.0.2.3.0.0.1.2.0.3.0.1.5.5.0.1.3.1.1.0.0.1.16.11.2.1.3.25.1.1.0'});{/script}
{tr class="contextArea"}
{td class="labelStandard"}
Request Type
{/td}
{td class="dataStandard" colspan="3"}
{div id="ticketRequestTypeObserverDiv" style="vertical-align: top; display: inline-block;"}
{select name="ChildPopup2030085045" id="12" style="margin-right: 5px; margin-bottom: 10px; float: left; display: inline-block;"}{option value="WONoSelectionString"}{/option}{option value="0"}Access Request{/option}{option value="1"}Change Requests{/option}{option value="2"}Classroom Technology{/option}{option value="3"}Computer{/option}{option value="4"}Data{/option}{option value="5"}Database{/option}{option value="6"}Email{/option}{option value="7"}Graphic Design{/option}{option value="8"}Intercom/Sound Systems/Scoreboard{/option}{option value="9"}INTERNAL USE ONLY System Configuration{/option}{option value="10"}Network & Internet{/option}{option value="11"}Password Reset{/option}{option value="12"}Phones & Voicemail{/option}{option value="13"}Printer/Copier{/option}{option value="14"}Purchasing/Orders{/option}{option value="15"}School Inventory Requests{/option}{option value="16"}Server{/option}{option value="17"}Software{/option}{option value="18"}Synergy{/option}{option value="19"}Tech Toolbox{/option}{option value="20"}z_Archived Request Types{/option}{/select}
{/div}{script}ASB.observeDescendentFields('NewDetailsPanelDiv', 'ticketRequestTypeObserverDiv', null, false, null, {onSuccess:function(e) { CustomFieldsUpdateContainerUpdate() }, _asbn:'7.21.0.0.0.0.2.3.0.0.1.2.0.3.0.1.5.5.0.1.3.1.1.0.0.1.16.11.2.1.3.25.1.1.0'});{/script}
{/td}
{/tr}
(There's probably a preferred method for posting HTML code in this forum. In the mean time I have replaced the pointy brackets with a curvy bracket to sidestep any display, code execution issues).
Here is my VBA code that I am using to manipulate this code. Previously I was side-stepping the problem by selecting the value above the one that I wanted, giving focus to that control and using send key to send a down arrow to this field to select the next item in the list. Because Internet Explorer saw this as a change to the select box, the AJAX code would trigger.
The problem with that technique (which is really a dirty work-around) is two-fold. 1.) It doesn't always fire correctly due to timing and that jettisons the rest of the code because certain containers and other controls are unhidden based on the value of these pull-down menus. 2.) Starting this morning this technique isn't working correctly on the parent control. I can step through my code and the code is correctly identifying and giving focus to that select tag, but the send key down is no longer working to select the next item in the list.
What I'd love to do is to select the correct item from the select box and then call directly the code that updates and shows the next select pull-down menu.
Code:
SelectRequestTypeParent:
'Wait Until Internet Explorer Is Not Busy
While IE.Busy Or IE.ReadyState <> READYSTATE_COMPLETE
DoEvents
Wend
'Wait One Additional 1 Second
Application.Wait Now + TimeSerial(0, 0, 1)
'Indentify Request Type Parent Select Tag By Count (This Select Drop-Down Is The Third Select Tag On The Page)
'I Couldn't Identify This Select Box By Name or ID Atrribute As These Values Change To Some Sudo-Random Value Each Refresh Of The Page
'Zero Out Counter
Count = 0
For Each l In IE.Document.getElementsByTagName("select")
'Increment Counter By One Each Loop
Count = Count + 1
'If The Select Tag Is The Third Tag Of It's Kind On The Page
If Count = "3" Then
'Get Focus On That Select Tag
l.Focus
'Set The Value Of That Select Tag To The Value Above The One Needed, I.E., To "Classroom Technology" (Item 3)
l.selectedIndex = 3
'Wait One Additional 1 Second
Application.Wait Now + TimeSerial(0, 0, 1)
'Get Focus On That Select Tag
l.Focus
'Send The Down Arrow Key To The Select Object In Order To Change It To "Computer" (Item 4)
'Because There Is A Yet Unidentified OnChange Event or JavaScript Code That Shows The Next Select Box When The Select Box Has Been Changed, I Couldn't Simply Assign The Value To This Select Box. Nor Have I Yet Identified The Script That Activates Showing The Next Select Tag, In Order To Cell It Directly. Thus, Using This Round About Method, Which Gets The Desired Result.
SendKeys "{down}"
GoTo SelectRequestTypeSub1
End If
Next[CODE]
So seeing this I have tried using Call CurrentWindow.execScript("ASB.observeDescendentFields('NewDetailsPanelDiv', 'ticketRequestTypeObserverDiv', null, false, null, {onSuccess:function(e) { CustomFieldsUpdateContainerUpdate() }, _asbn:'7.21.0.0.0.0.2.3.0.0.1.2.0.3.0.1.5.5.0.1.3.1.1.0.0.1.16.11.2.1.3.25.1.1.0'}")
But while this doesn't produce any errors, it doesn't actually appear to execute anything or to update the field in any way.
I also tried using Call CurrentWindow.execScript to call just the { CustomFieldsUpdateContainerUpdate() }, _asbn:'7.21.0.0.0.0.2.3.0.0.1.2.0.3.0.1.5.5.0.1.3.1.1.0.0.1.16.11.2.1.3.25.1.1.0'}") portion, to no avail.
Does anybody have any ideas for me or see something that I am doing wrong?
Thanks much,
Last edited: