RE: [PHP] how do you reference the previous field in a form?
| From: | Layne Weathers | Date: | Mon, 27 Nov 2000 21:15:39 +0000 |
| Subject: | RE: [PHP] how do you reference the previous field in a form? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-27467@lists.php.net to get a copy of this message | ||
> How do I reference the value of the field one prior to the
> one calling the
> function? I know that I can do it manually like this:
>
> document.forms[0][elements[0]
I would be predisposed to passing the info to the function as a second
parameter, but that's just me. You could also try something like this
(untested, from the top of my head):
<script>
<!--
function setValue(mod_from) {
var num_elements = document.real.elements.length;
for(i=0; i<num_elements; i++) {
if(document.real.elements[i].name == mod_from.name) {
var prev_element = i;
}
}
document.real.elements[prev_element].value = mod_from.value;
}
//-->
</script>
<form name=real>
<input type=text name=something>
<select name=else onChange="setValue(this);">
blah
</form>
Layne Weathers
Ifworld, Inc.
layne@ifworld.com