IndyB
08-06-2003, 02:39 PM
I've got a form that's being dynamically generated. I need to do some calculations with one of the fields when the user clicks a link. But I'm not handling the dynamic form field properly, b/c when I reference it in the script it comes up as undefined.
Anyone see what I'm doing wrong here?
The form field in question is:
<input type="text" name="units_#page.set_id#_#page.line_id#" value="1" size="3" onchange="if(isNaN(this.value)) {alert('Units must be a number.'); this.value='1'; this.focus()}">
The link the user clicks on is:
<a href="" onClick="place_fee(#rate#);">#procedure_code# </a>
Here's the JS to handle the calculations:
function place_fee(fee)
{
set_id = '#page.set_id#';
line_id = '#page.line_id#';
unitVal = eval("document.frmLookup.units_"+set_id+"_"+line_id+".value");
ur = unitVal * fee;
line_amount = '#url.line_amount#';
ineligible_field_name = '#url.ineligible_field#';
ineligible = 0;
if(line_amount - ur < 0)
{ ineligible = 0; }
else if(line_amount - ur > 0)
{ ineligible = line_amount - ur; }
alert(unitVal);
alert(ur);
alert(line_amount);
alert(ineligible);
opener.document.frmpage[ineligible_field_name].value = ineligible;
self.close();
}
Anyone see what I'm doing wrong here?
The form field in question is:
<input type="text" name="units_#page.set_id#_#page.line_id#" value="1" size="3" onchange="if(isNaN(this.value)) {alert('Units must be a number.'); this.value='1'; this.focus()}">
The link the user clicks on is:
<a href="" onClick="place_fee(#rate#);">#procedure_code# </a>
Here's the JS to handle the calculations:
function place_fee(fee)
{
set_id = '#page.set_id#';
line_id = '#page.line_id#';
unitVal = eval("document.frmLookup.units_"+set_id+"_"+line_id+".value");
ur = unitVal * fee;
line_amount = '#url.line_amount#';
ineligible_field_name = '#url.ineligible_field#';
ineligible = 0;
if(line_amount - ur < 0)
{ ineligible = 0; }
else if(line_amount - ur > 0)
{ ineligible = line_amount - ur; }
alert(unitVal);
alert(ur);
alert(line_amount);
alert(ineligible);
opener.document.frmpage[ineligible_field_name].value = ineligible;
self.close();
}