Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing a variable from function to a form field

Status
Not open for further replies.

lucyc

Programmer
Mar 1, 2002
62
US
I don't know how to pass a variable from a function to a form field, here is the code:

function Calc(){

var CS = parseFloat(IncDecForm.CurrentSalary.value)
var I = parseFloat(IncDecForm.IncrDecr.value)
var MxSal= IncDecForm.MaxSal.value
var MxSal= parseFloat(MxSal,10)

var NS = CS * ( 1 + I * .01 )
var Diff = MxSal - CS
var DiffPct = (Diff * 100)/CS
var NPercent

if (NS > MxSal)
{

NPercent = DiffPct;
alert("new percent : " + NPercent);
alert("Error:New salary exceeds Pay Band Maximum !! " + DiffPct + "%")
}
else if (NS <= MxSal)
{
NPercent = (IncDecForm.IncrDecr.value);
alert(&quot;new percent : &quot; + NPercent);
}
}

<form name=IncDecForm>
<table border=&quot;0&quot; width=&quot;732&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr>
<td> Enter Increase/Decrease(%) :</font>&nbsp;<input type=&quot;text&quot; name=&quot;IncrDecr&quot;
size=&quot;12&quot; tabindex=&quot;3&quot; value=&quot; &quot; onBlur=&quot;Verify();Calc();ValidInBand();&quot;> <input type=&quot;text&quot; name=&quot;intNPercent&quot; value=&quot;?????????&quot;> </td>

I would like to know how can I get the NPercent value to the field name intNPercent. Please help. Thanks.
 
Hi onpnt,

Where should I put it??
 
anywhere after you have made your final adjsutments to the value of the varaible in the function
try after the alert My most satisfying and best work has come from helping others

admin@onpntwebdesigns.com
 
Thank you, thank you,thank you,thank you,thank you,thank you,thank you,thank you,.....................
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top