Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   dynamically set textboxes (http://www.velocityreviews.com/forums/t871941-dynamically-set-textboxes.html)

Ben Dover - Mental Patient 0057 08-28-2003 02:28 PM

dynamically set textboxes
 
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";
document.main.aaa.focus();
}


----------------
<form name="main">
<input type="text" value="aaa" name="boxaaa">
<input type="text" value="bbb" name="boxbbb">
<input type="button" value="clickme" onclick="clearBox(aaa)">
<input type="button" value="clickme" onclick="clearBox(bbb)">
</form>

Lasse Reichstein Nielsen 08-28-2003 04:25 PM

Re: dynamically set textboxes
 
Ben Dover - Mental Patient 0057 <Ben_Dover@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 - lrn@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'

Ben Dover - Mental Patient 0057 08-28-2003 06:31 PM

Re: dynamically set textboxes
 
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 <Ben_Dover@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 - lrn@hotpop.com
> Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
> 'Faith without judgement merely degrades the spirit divine.'



All times are GMT. The time now is 07:54 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.