Hello all,
I am having trouble with getting a javascript function to execute in vba. My script so far takes me to the website, logs in, goes to the correct page, and changes the drop down menu to the correct option. On this dropdown menu page there is no submit button until the drop down changes and I use .FireEvent (onchange) to make the submit button appear. The trouble I am having is with pressing the submit button which will open the new window. It seems that the submit is in a Function which I do not know how to manipulate in vba.
The script that shows where I run the javascript to get the submit button to appear is shown below.
With .document
' select shareholding
Set SecName = .getElementsByName("ctl00$ContentPlaceHolder1$RptSel$ddlReport")
SecName(0).Value = "279"
Set objURLpage = ie.document
Set objSELECTelement = objURLpage.getElementById("ctl00$ContentPlaceHolder1$RptSel$ddlReport")
objSELECTelement.selectedIndex = 2
objSELECTelement.FireEvent ("onchange")
With appIE
End With
This is the source code showing the javascript which references a doPostBack
onchange="javascript:setTimeout('__doPostBack(\'ctl00$ContentPlaceHolder1$RptSel$ddlReport\',\'\')', 0)" id="ctl00_ContentPlaceHolder1_RptSel_ddlReport">
This is the source code for the post back function which I assume is what I need to hit submit.
<
scripttype="text/javascript">
//<![CDATA[
var
theForm = document.forms['aspnetForm'];
if
(!theForm) {
theForm = document.aspnetForm;
}
function
__doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
Any help with this would be greatly appreciated. If any more information is needed please do let me know and I will provide what I can.
Thanks!