View Single Post
Old 06-07-2007, 02:01 AM   PM User | #11
djmonkey1
New Coder

 
Join Date: Mar 2006
Location: In an apartment.
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
djmonkey1 is an unknown quantity at this point
Quote:
Originally Posted by glenngv View Post
Is totalsBlock inside the form tag?
Yes.

Quote:
Can you post a sample of the generated form field tags returned by responseText?
Code:
        <tr class="dataTableRow">
                    <td class="dataTableContent" height="15" valign="middle"><span id="update_totals[2]"><a href="javascript:setCustomOTVisibility('update_totals[3]', 'visible', 'update_totals[2]');"><img src="images/plus.gif" alt="Insert new custom order total after this one" title=" Insert new custom order total after this one " border="0"></a></span></td>
                    <td class="dataTableContent" align="right"><input name="update_totals[2][title]" value="Tax:" readonly="readonly"></td>

                    <td class="dataTableContent" align="right" nowrap="nowrap">$166.51<input name="update_totals[2][value]" value="166.51" type="hidden"><input name="update_totals[2][class]" value="ot_tax" type="hidden"></td>
                  </tr>
Quote:
But why not just generate the values of the totals excluding the field tags? Something like this.

Code:
100.00|5.00|110.00
And then just split it to get each total and update the corresponding field.

Code:
var totals = http_request.responseText.split("|");
if (totals.length==3){ //change 3 to number of totals you are expecting
  //update the corresponding fields
  var frm=document.formNameHere;
  frm.whateverField1.value = totals[0];
  frm.whateverField2.value = totals[1];
  frm.whateverField3.value = totals[2];
}
The number of totals fields is variable and can change every time data is submitted from the form.

Couldn't I use a regular expression to pull just the update_totals array from the form? That was what I originally tried to do, but couldn't get it to work. For example if I had something like
Code:
var data = document.getElementsByName(updateTotals);
and
Code:
var updateTotals = /^update_totals/;

Last edited by djmonkey1; 06-07-2007 at 02:45 AM.. Reason: syntax error
djmonkey1 is offline   Reply With Quote