By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,461 Members | 1,135 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,461 IT Pros & Developers. It's quick & easy.

firefox does not get elements by name

P: 1
this piece of code does not seem to work with firefox however works without any problem on chrome or IE:

Expand|Select|Wrap|Line Numbers
  1. f = document.forms["form1"];
  2. var nombre = f.elements.item("nombre").value;
  3. var email = f.elements.item("email").value;
  4. var coment = f.elements.item("coment").value;
instead of assigning the corresponding value to the variables it just repeats the same value for all the variables so assuming the input nombre has the value john email and coment will also have john even though in the input boxes fom the form the values are different.

So how to I check the values accordingly?

Dec 13 '11 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 15k+
P: 16,027
Try f.elements["email"].value

Alternatively, give each element an ID and access using document.getElementById().

Failing that, post the HTML code.
Dec 16 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.