Connecting Tech Pros Worldwide Help | Site Map

JS function is not working in IE

AMT India's Avatar
Member
 
Join Date: Feb 2007
Posts: 64
#1: Oct 8 '07
This JS function is not working in IE 6 and 7..

Expand|Select|Wrap|Line Numbers
  1. function ValidateRows( checkbox_id ){    
  2.  
  3.     if( document.pageform.eval(checkbox_id).value){
  4.  
  5.         if ( document.pageform.eval(checkbox_id).checked ){
  6.             return true;
  7.         }
  8.     }
  9.     for ( var i=0; i < document.pageform.eval(checkbox_id).length;i ++ ){
  10.         if ( document.pageform.eval(checkbox_id)[i].checked ){
  11.             return true;
  12.         }
  13.     }
  14.     return false;
  15. }
  16.  
The error is 'Object does not support this property or method'. The error line number is the first line of the function.
dmjpro's Avatar
Lives Here
 
Join Date: Jan 2007
Location: India (West-Bengal)
Posts: 2,451
#2: Oct 8 '07

re: JS function is not working in IE


Quote:

Originally Posted by AMT India

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

Expand|Select|Wrap|Line Numbers
  1. function ValidateRows( checkbox_id ){    
  2.  
  3.     if( document.pageform.eval(checkbox_id).value){
  4.  
  5.         if ( document.pageform.eval(checkbox_id).checked ){
  6.             return true;
  7.         }
  8.     }
  9.     for ( var i=0; i < document.pageform.eval(checkbox_id).length;i ++ ){
  10.         if ( document.pageform.eval(checkbox_id)[i].checked ){
  11.             return true;
  12.         }
  13.     }
  14.     return false;
  15. }
  16.  
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 ............
Expand|Select|Wrap|Line Numbers
  1. eval("document.pageform.checkbox_id").value
  2.  
instead of ............... "document.pageform.eval(checkbox_id).value"

Debasis Jana
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,126
#3: Oct 8 '07

re: JS function is not working in IE


hi ...

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

Expand|Select|Wrap|Line Numbers
  1. document.pageform[checkbox_id].value
kind regards
AMT India's Avatar
Member
 
Join Date: Feb 2007
Posts: 64
#4: Oct 8 '07

re: JS function is not working in IE


Quote:

Originally Posted by gits

hi ...

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

Expand|Select|Wrap|Line Numbers
  1. document.pageform[checkbox_id].value
kind regards


Thanx for the replies....Both of the above code is working in IE....but not in Firefox....
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,126
#5: Oct 8 '07

re: JS function is not working in IE


hi ...

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

Expand|Select|Wrap|Line Numbers
  1. var node = document.getElementById('your_id');
  2.  
and for the value you may then use:

Expand|Select|Wrap|Line Numbers
  1. var val = node.value;
kind regards
Reply