Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using JavaScript variable in a input field

Status
Not open for further replies.

lyric0n

Technical User
Joined
Dec 28, 2005
Messages
74
What I have is a JavaScript variable that is assigned a value from a previous page. This works fine and dandy. But now, I would like to have an input box, with the default value being that variable.

I have tried using the...

<input type="text" name="blah" value="JAVASCRIPT VARIABLE!">

...but it just puts any code I put there into the box, rather than process it.

How would I make this work?
Thanks,
Chris
 
there are a couple of ways to do this, one being through the onload event of the body:

Code:
<body onload="document.forms['myFormName'].elements['myFieldName'].value = myVarName;">



*cLFlaVA
----------------------------
[tt]( <P> <B>)13 * (<P> <.</B>)[/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top