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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JS & Forms

Status
Not open for further replies.

MysticFallout

Technical User
Sep 21, 2002
14
US
i am having a major issue here. i am trying to populate a form textbox but nothing happens. i am using an external .js file and on my page i have the form set up like. i use XHTML strict.

Code:
<form name=&quot;test_form&quot; id=&quot;test_form&quot;>
<input type=&quot;text&quot; name=&quot;test_text&quot; id=&quot;test_text&quot;>
</form>

and my JS looks like.

Code:
document.test_form.test_text.value = &quot;Hello&quot;;

i use Mozilla, and when i use the JavaScript console it says document.test_form has no properties. any ideas? i know SOME JS, (just havent used it in over 2 years), so i am sure i am doing something wrong.
 

That should work fine if you've remembered to wait until the page is loaded before you try setting the value.

Have you?

Code:
window.onload = function() {

document.test_form.test_text.value = &quot;Hello&quot;;

}
 
i see, i was trying to populate the form before the form was even rendered. thank you very much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top