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

need to dinamically update a field in a form.

Status
Not open for further replies.

SvenBlackwood

Programmer
Feb 18, 2008
2
MX
Here is my problem I need to send a form that takes values from field a and field b, but then when the form is sent, sends values a+b in another field, along with a bunch of fields.

i.e.

<input type="text" name="a"></input>
<input type="text" name="b"></input>

...
<input type="text" name="ab"></input>
<input type="text" name="ac"></input>
...

<input type="hidden" name="c" value="javascript:a + b"></input>

or something like that. I tried adding an onchange, but not sure how to send the value to be updated in the field "c"

any help will be highly appreciated.
 
Here is a similar scenario - hopefully you can use some of it...

Code:
<html><head>
<script type="text/javascript">
window['checkForm'] = function() {
  var frm = document.forms['frm'].elements;
  frm['c'].value = frm['a'].value - 0 + frm['b'].value;
};
</script>
</head><body><form name="frm" action="" onsubmit="checkForm()">
<fieldset><legend></legend>
<input type="text" name="a" value="" onchange="checkForm()">
<input type="text" name="b" value="" onchange="checkForm()">
<input type="hidden" name="c" value="">
<input type="submit" name="submit" value="Send">
</fieldset></form>
</body></html>

Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Thanks mate, you are the best indeed... it was so simple i could kill myself. ;)

sven
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top