pnoeric
asked on
get value for form field
See sample code below-- note two forms with identically named 'phone number' fields. In JS, I want to get the value for 'phone' from the form that the user submitted. (This is a small example -- I have dozens of fields in the real forms... so I don't want to give every single field in each form its own unique ID.)
<form id='form1'>
phone number: <input name='phone'>
<input type='submit' onClick="validate('form1');">
</form>
<form id='form2'>
phone number: <input name='phone'>
<input type='submit' onClick="validate('form2');">
</form>
then in the JS...
<script>
function validate(f) {
// note that f == 'form1' or 'form2'
// how do I get the value of the 'phone' field from the form the user submitted?
// I'm using the Prototype library, if it helps...
}
</script>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
dvz, that won't work because he's passing in the string name for the form.
jonah, ah thanks for the correction.
i believe