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

Why isnt this working?

Status
Not open for further replies.

elegidito

Programmer
Jan 19, 2002
358
I'm creating a cookie containing the value of the input box, named 'input1' in a form named 'form1', but it says that document.form1.input1.value is null or not an object, could someone look at it for me?

heres the page:
thanks a lot!
The pen is mightier than the sword.
 
Keep in mind that scripts written in the <head> are executed before any of the page is rendered.
Code:
document.form1
doesn't exist at the time the script is executed.

There are two solutions:
1. Put the script in the <body>
2. Put the script in a function called by
Code:
document.onload

Personally, when I make scripts, I usually put them in the <body> to make sure they work right no matter what.


Note:
In browsers that accept
Code:
document.body
, it is
Code:
null
if your script is executed right away in the <head>.
 
doh, that was quite a stupid mistake, heh.

thank you The pen is mightier than the sword.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top