JS function is not working in IE

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AMT India
    New Member
    • Feb 2007
    • 64

    JS function is not working in IE

    This JS function is not working in IE 6 and 7..

    [CODE=javascript]
    function ValidateRows( checkbox_id ){

    if( document.pagefo rm.eval(checkbo x_id).value){

    if ( document.pagefo rm.eval(checkbo x_id).checked ){
    return true;
    }
    }
    for ( var i=0; i < document.pagefo rm.eval(checkbo x_id).length;i ++ ){
    if ( document.pagefo rm.eval(checkbo x_id)[i].checked ){
    return true;
    }
    }
    return false;
    }
    [/CODE]
    The error is 'Object does not support this property or method'. The error line number is the first line of the function.
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    Originally posted by AMT India
    This JS function is not working in IE 6 and 7..

    [CODE=javascript]
    function ValidateRows( checkbox_id ){

    if( document.pagefo rm.eval(checkbo x_id).value){

    if ( document.pagefo rm.eval(checkbo x_id).checked ){
    return true;
    }
    }
    for ( var i=0; i < document.pagefo rm.eval(checkbo x_id).length;i ++ ){
    if ( document.pagefo rm.eval(checkbo x_id)[i].checked ){
    return true;
    }
    }
    return false;
    }
    [/CODE]
    The error is 'Object does not support this property or method'. The error line number is the first line of the function.
    "eval" is a member function of "window" object.

    You should use like ............
    [code=javascript]
    eval("document. pageform.checkb ox_id").value
    [/code]

    instead of ............... "document.pagef orm.eval(checkb ox_id).value"

    Debasis Jana

    Comment

    • gits
      Recognized Expert Moderator Expert
      • May 2007
      • 5390

      #3
      hi ...

      you don't need eval at all here ... simply use the correct reference (array-like in this case):

      [CODE=javascript]document.pagefo rm[checkbox_id].value[/CODE]
      kind regards

      Comment

      • AMT India
        New Member
        • Feb 2007
        • 64

        #4
        Originally posted by gits
        hi ...

        you don't need eval at all here ... simply use the correct reference (array-like in this case):

        [CODE=javascript]document.pagefo rm[checkbox_id].value[/CODE]
        kind regards

        Thanx for the replies....Both of the above code is working in IE....but not in Firefox....

        Comment

        • gits
          Recognized Expert Moderator Expert
          • May 2007
          • 5390

          #5
          hi ...

          simply use the standards-compliant method to retrieve the nodes:

          [CODE=javascript]var node = document.getEle mentById('your_ id');
          [/CODE]
          and for the value you may then use:

          [CODE=javascript]var val = node.value;[/CODE]
          kind regards

          Comment

          Working...