Reputation: 11
Rather new to javascript and using it for web scraping purposes. Updating a value of an element being sent in the doPostBack method is causing an error and I am not sure if what I am attempting is possible or if there is more parts to it.
The method is tied to an onchange event and what I am trying to do is just show more results on a webpage. I updated the value/textContent for the second option to 100 in the select and tried to click it.
<select name="ctl00$MainCol$Pager$ddlPageSize" onchange="javascript:setTimeout('__doPostBack(\'ctl00$MainCol$Pager$ddlPageSize\',\'\')', 0)" id="ctl00_MainCol_Pager_ddlPageSize">
<option selected="selected" value="10">10</option>
<option value="25">25</option>
<option value="50">50</option>
<script type="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();
}
}
//]]>
</script>
My hope was this would work and show 100 results (Which does initially on the non-updated page) but clearly I don't know enough about doPostBack as this went to an error page where I got a "Page Cannot be Found" message. I am just wondering what else is at play here that is causing this not to work. My guess is theres a function on the other end that can only handle certain values but I am not really sure so any insight would be great.
Upvotes: 1
Views: 39