Quote:
Originally Posted by glenngv
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.
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/;