IE not allowing adding diff proprties to an element, Y?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Amzul
    New Member
    • Oct 2007
    • 130

    IE not allowing adding diff proprties to an element, Y?

    hello all,

    i have a form with 6 elemnt:

    [CODE=html]<label><input type="radio" name="name_b" value="120x60" checked="checke d"/>120x60</label><!-- #1 -->
    <input type="radio" name="name_b" value="468x60" />468x60</label><!--#2-->
    <input type="text" size="6" id="wx" name="wx" value="200" checked="checke d"/><!--#3 notice the checked="checke d" i add -->
    <input type="text" size="6" id="wy" name="wy" value="200" checked="checke d"/><!--#4 -->
    <input type="text" size="40" id="path" name="path" value="i need this value" checked="checke d" /><!--#5-->
    <input type="submit" value="go" /><!--#6-->[/CODE]

    what i want to do (and manage to do it with FF but not with IE) is to get the elements that are sepose to b send to the server, here is the function i use

    [CODE=javascript] x=document.form s['myform_name'];
    f="elements i need from my form\n";
    for(i=0; i<(x.elements.l ength-1); i++){//-1 cuz i dont need the submit button
    if(x.elements[i].checked){//thats y i add the checked to the elements
    f+=x.elements[i].value;
    f+="\n";
    }
    alert(f);
    }[/CODE]

    is there a short way for IE as well ?
  • pronerd
    Recognized Expert Contributor
    • Nov 2006
    • 392

    #2
    I do not think it is valid to have the checked attribute any type of input fields other than checkboxes. That is probably what the "if(x.eleme nts[i].checked)" if test is failing and causing that code to not be executed.

    Comment

    • Amzul
      New Member
      • Oct 2007
      • 130

      #3
      Originally posted by pronerd
      I do not think it is valid to have the checked attribute any type of input fields other than checkboxes. That is probably what the "if(x.eleme nts[i].checked)" if test is failing and causing that code to not be executed.
      i know its not valid, just wonder why IE cant be more flexible, or maybe there is somthing similler i can use to di the same.

      i want the form data without submiting it to the server, keep it on the clint side.
      just wonder what if it was a realy long form with alot of elements....

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Use, for example, the class attribute instead. Then use className to check the class of the form elements.

        Comment

        Working...