469,622 Members | 1,462 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Javascript null

Hi,

Could anyone tell me why this...

document.forms[0].elements[i].value=null;

....appears to be assigning the actual string value of "null" to my form
element, rather than actually nullifying it?

Oct 25 '05 #1
2 15408
VK

mj.redfox...@gmail.com wrote:
Hi,

Could anyone tell me why this...

document.forms[0].elements[i].value=null;

...appears to be assigning the actual string value of "null" to my form
element, rather than actually nullifying it?


Because all form element values are stored as strings and any value
will be converted to string before being assigned. And string
representation of null is "null".
To clear an element value set it to empty string:
document.forms[0].elements[i].value="";

Oct 25 '05 #2
Thanks, wasn't sure if that would definitely nullify it or not, but I
suppose it's just the same as leaving a field blank.

Oct 25 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by George Hester | last post: by
6 posts views Thread by Alex Fitzpatrick | last post: by
4 posts views Thread by JesusFreak | last post: by
7 posts views Thread by Marci | last post: by
2 posts views Thread by Jackson Yap | last post: by
The1corrupted
6 posts views Thread by The1corrupted | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.