OrcaSoul 0 Newbie Poster

I am rewriting a Python mechanize script to parse a site, after the entire site was altered...

I am able to get part way into the pages I need to access, but have run into a bit of a problem.

In the HTML below, the first segment has 2 buttons - one sets all selections to TRUE (Check all), the other sets all selections to FALSE (Uncheck all). These affect all selections in the form that follows, and are outside of the form I need to submit.

<!--  These are the Check all/Uncheck all buttons ############# orca       -->
      
  <script type="text/javascript" src="/skin1/change_all_checkboxes.js"></script>
<div>
  <a href="javascript:void(0);" onclick="javascript: checkAll(true, document.processorderform, 'orderids');">Check all</a>
  /
  <a href="javascript:void(0);" onclick="javascript: checkAll(false, document.processorderform, 'orderids');">Uncheck all</a>
</div>

The second segment - the form itself - has a 'submit' button that uses the setting of the selections to access another page that shows the selected orders.

<!--  Then the form starts ############# orca       -->

  <form action="process_order.php" method="post" name="processorderform">
    <input type="hidden" name="mode" value="" />
    <table cellspacing="1" class="data-table width-100" summary="Search results">
      <tr class="head-row">
      	<th class="data-checkbox-column">&nbsp;</th>
      	<th><a href="orders.php?mode=search&amp;sort=orderid">#</a></th>
      	<th><a href="orders.php?mode=search&amp;sort=status">Status</a></th>
        <th><a href="orders.php?mode=search&amp;sort=date">Date</a></th>
        <th><a href="orders.php?mode=search&amp;sort=total">Total</a></th>
      </tr>
        <tr>
        	<td><input type="checkbox" name="orderids[130327]" /></td>
        	<td><a href="order.php?orderid=130327">#130327</a></td>
        	<td>
            <a href="order.php?orderid=130327">
            	<strong>Processed</strong>
			</a>
		  </td>
          <td><a href="order.php?orderid=130327">01/26/2009 12:50:03</a></td>
        	<td class="data-right-column"><a href="order.php?orderid=130327"><span class="currency">$22.96</span></a></td>
        </tr>
        <tr class="subhead-row">
        	<td><input type="checkbox" name="orderids[130147]" /></td>
        	<td><a href="order.php?orderid=130147">#130147</a></td>
        	<td>
            <a href="order.php?orderid=130147">
            	<strong>Processed</strong>
			</a>
          </td>
          <td><a href="order.php?orderid=130147">01/22/2009 22:41:43</a></td>
        	<td class="data-right-column"><a href="order.php?orderid=130147"><span class="currency">$5.00</span></a></td>
        </tr>
      
      <tr>
      	<td colspan="5" class="data-right-column">Gross total: <strong><span class="currency">$27.96</span></strong></td>
      </tr>
      <tr>
      	<td colspan="5" class="data-right-column">Total paid: <strong><span class="currency">$27.96</span></strong></td>
      </tr>
    </table>
    
    <div class="button-row">
    
<!-- This is the submit button ############# orca     -->            
  
  <button class="button" type="button" title="Invoices for selected" onclick="javascript: if (!checkMarks(document.processorderform, new RegExp('orderids\[[0-9]+\]', 'gi'))) return false; document.processorderform.target = 'invoices'; submitForm(this, 'invoice'); document.processorderform.target = '';">
  <span class="button-right"><span class="button-left">Invoices for selected</span></span>
  </button>
    </div>
  </form>
</div>

My problem is that both the buttons at the top, and the submit button at the botton, use embedded javascript to determine their actions.

Is there a way using Mechanize to set the 'Check all' button true, and then submit the form? Or would another method work better?

I am able to open and read the page with the following code, but that's as far as it will let me go.
Note: openNextPage() is a funtion that uses Mechanize to open a browser session...

OrdersManagementFile = openNextPage(openOrdersManagementURL)
	if OrdersManagementFile:
		OrdersManagementBaseStr = OrdersManagementFile.read()
		OrdersManagementFile.close()
		
		orderForm = br.select_form(name="processorderform") # Browser opens form
		response = br.submit()
		url = response.geturl()
		pageText = response.read()
		response.close()
		print "Begin response at " + url + ":\n================\n" + pageText + "\n==============\nEnd pageText\n"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.