470,637 Members | 1,682 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,637 developers. It's quick & easy.

Help: Document object's property

How do I use a variable value within the document object's property?

That is, if I have:

document.profile_form.firstname.value=fname;

How do I make it more generic, like this:

desired=fieldname
document.profile_form.desired.value=fname;

Where firstname is the current field name.

Craig

w1******@hotSPAMmail.com (remove SPAM befor emailing)
Jul 20 '05 #1
3 1436
In article <9-********************@comcast.com>, w1zard10
@hotSPAMmail.com enlightened us with...
How do I use a variable value within the document object's property?

That is, if I have:

document.profile_form.firstname.value=fname;

How do I make it more generic, like this:

desired=fieldname

If you had the name of a field and wanted dynamic addressing...

desired = "firstname";
document.forms["formname"].elements[desired].value = somevalue;

--
--
~kaeli~
A midget fortune teller who escapes from prison is a small
medium at large.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #2
"Craig L" <w1******@hotSPAMmail.com> writes:
How do I use a variable value within the document object's property?


<URL: http://jibbering.com/faq/#FAQ4_39 >
Good luck :)
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3
Thanks. It worked out great.

Craig

"kaeli" <ti******@NOSPAM.comcast.net> wrote in message
news:MP************************@nntp.lucent.com...
In article <9-********************@comcast.com>, w1zard10
@hotSPAMmail.com enlightened us with...
How do I use a variable value within the document object's property?

That is, if I have:

document.profile_form.firstname.value=fname;

How do I make it more generic, like this:

desired=fieldname

If you had the name of a field and wanted dynamic addressing...

desired = "firstname";
document.forms["formname"].elements[desired].value = somevalue;

--
--
~kaeli~
A midget fortune teller who escapes from prison is a small
medium at large.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Aaron | last post: by
12 posts views Thread by Kepler | last post: by
1 post views Thread by Korara | last post: by
???
1 post views Thread by Stoney L | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.