firefox does not get elements by name

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Hector Daniel
    New Member
    • Dec 2011
    • 1

    #1

    firefox does not get elements by name

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

    Code:
    f = document.forms["form1"];
    var nombre = f.elements.item("nombre").value;
    var email = f.elements.item("email").value;
    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?

    Regards
    Last edited by gits; Dec 14 '11, 08:54 AM. Reason: added code tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Try f.elements["email"].value

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

    Failing that, post the HTML code.

    Comment

    Working...