[Javascript] Form focus
Shawn Milo
milo at linuxmail.org
Mon May 10 08:29:14 CDT 2004
George,
Welcome to the group.
I'm not sure I completely understand what you're trying to do with the
single fields. I'm assuming that the second button will also submit the
form, though. If this is the case, then you can have Javascript in the
onchange event of each textbox, which sets the value of an HTML object,
type 'hidden'. Something like this:
<form id="testForm" method="post" action="./action.php">
<input type="hidden" id="hiddenFieldID" name="hiddenFieldID" value="" />
<input type="text" id="field01" id="field01" onchange="document.forms['testForm'].hiddenFieldID.value = this.id;" value="" /><br/>
<input type="text" id="field02" id="field02" onchange="document.forms['testForm'].hiddenFieldID.value = this.id;" value="" /><br/>
</form>
I didn't include a submit button here, and there is no handling for someone who edits
more than one text box then tries to use your second button. But I think the basics
are here, and you can use the value of the hidden server-side to know which field
to single out.
I'm sure others will correct/enhance my suggestion if I'm doing this the hard way.
Shawn
More information about the Javascript
mailing list