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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing values in form to output page

Status
Not open for further replies.

greatfalls

Technical User
Jul 1, 2001
21
0
0
CA
I have a javascript that is doing a calculation and displaying some dollar values and I would like to display them on the output page as well, but the name of each field is the same. Which is name="salHistory" Is this possible?

function chkCurrency(fld) {
// insure currency input (no numeric sign allowed)
var str = fld.value.replace(/\$|\,|\s/g,'');
if (!/^[0-9]+\.?[0-9]{0,2}$/.test(str)) {
window.alert("This must be a valid currency value.");
fld.focus();
fld.select();
return false;
}
fld.value = fmtCurrency(str);
// check field priorities
if (fld.name=="aveSalary") {
for (var i=0; i<fld.form.salHistory.length; i++) {
fld.form.salHistory.value = &quot;&quot;;
}
} else {
var cnt = 0, sum = 0;
for (var i=0; i<fld.form.salHistory.length; i++) {
if (fld.form.salHistory.value.length == 0) break;
cnt++;
sum += Number(fld.form.salHistory.value.replace(/\$|\,|\s/g,''));
}
for (i; i<fld.form.salHistory.length; i++) {
if (fld.form.salHistory.value.length > 0) break;
}
if (i<fld.form.salHistory.length) {
window.alert(&quot;Cannot skip a salary history year.&quot;);
fld.form.salHistory[cnt].focus();
fld.form.salHistory[cnt].select();
return false;
}
str = (sum/cnt).toString();
fld.form.aveSalary.value = fmtCurrency(str);
}
return true;
}



<input type=&quot;text&quot; name=&quot;salHistory&quot; tabindex=&quot;20&quot; size=&quot;6&quot; onChange=&quot;return chkCurrency(this);&quot;>

<input type=&quot;text&quot; name=&quot;salHistory&quot; tabindex=&quot;21&quot; size=&quot;6&quot; onChange=&quot;return chkCurrency(this);&quot;>
 
could you please explain more in details what problem you have - so that we can really fully help you ?
what i understand is :
- you have 2 fields named the same name ('salHistory'), when their value changes, you call the 'chkCurrency' function
- this function does some calculation and then (eventually) updates the 'aveSalary' field

so, is the value not displaying in the aveSalary field ? or is it ? do you want it to be displayed some other place ? what do you call the output page, this one or another one ? - and where is it related to coldfusion ?

i need these answers, to help you better - me, or anyone else here...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top