just want to share with everyone what I put together:
in the head:
function clearBox(inputobject) {
var obj=(inputobject);
document.main[inputobject].value="";
document.main[inputobject].focus();
}
in the body:
<form name="main" >
<INPUT TYPE="TEXT" VALUE="helloworld" NAME="login">
<a href="#" onclick="clearBox('login');">clear login</a>
<INPUT TYPE="TEXT" VALUE="helloworld" NAME="password">
<a href="#" onclick="clearBox('password');">clear password</a>
etc...
</form>
have fun folks!
Lasse Reichstein Nielsen wrote:
Ben Dover - Mental Patient 0057 <Be*******@psychiatric-center.Bellevue-Hospital.com> writes:
i want to be able to dynamically set different text boxes depending on
the button pressed.
i was hoping obj() can "become" object "aaa" or "bbb", but it's not
working.
function clearBox(inputobject) {
var obj=(inputobject);
document.main.ojb().value="hello";
From the FAQ <URL:http://jibbering.com/faq/#FAQ4_39>
document.forms['main'].elements[inputobject].value="hello";
(I prefer to always use the forms and elements collections)
This also requires that the remaining code is correct :
<input type="text" value="aaa" name="boxaaa">
<input type="text" value="bbb" name="boxbbb">
<input type="button" value="clickme" onclick="clearBox(aaa)">
onclick="clearBox('aaa')"
You want to send a string, not the value of the possibly non-existing
global variable called "aaa".
<input type="button" value="clickme" onclick="clearBox(bbb)">
Ditto here.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'