/    Sign up×
Community /Pin to ProfileBookmark

dynamic form fields problem

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();
}

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliAug 06.2003 — post a link to th epage if possible or post some more code including form
×

Success!

Help @IndyB spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...