469,610 Members | 2,511 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,610 developers. It's quick & easy.

Javascript - another Object Expected error when executing javascript function

I am having a problem running a javascript function as part of an html-el:form onsubmit. The problem seems to exists in IE6 but not in Firefox.

html:
Expand|Select|Wrap|Line Numbers
  1. <html-el:form action="${target}" onsubmit="return testTheForm(this)">
  2.  
javascript function:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function testTheForm(theForm){
  3.  var e;
  4.  for (i=0; i<theForm.elements.length; i++){
  5.   e = theForm.elements[i];
  6.   if (e.nodeName == 'SELECT')
  7.   { if (!e.disabled && e.selectedIndex == -1){return false;} }
  8.  }
  9.  return true;
  10. }
  11. </script>
  12.  
When I click on the Submit button I get Error on Page that displays an Object Expected error.

This works fine on Firefox as well as when I put the code inline as part of the onsubmit:
Expand|Select|Wrap|Line Numbers
  1. <html-el:form action="${target}" onsubmit="for (i=0; i<this.elements.length; i++){
  2.   var e = this.elements[i];
  3.   if (e.nodeName == 'SELECT')
  4.   { if (!e.disabled && e.selectedIndex == -1){return false;} }
  5.  }return true;">
  6.  
Note the javascript function is declared in the same .jsp as the html-el:form tag.

Any ideas? I have googled this error with no satisfactory solutions yet.

Thanks.

-Tim
Aug 9 '07 #1
1 2401
pbmods
5,821 Expert 4TB
Heya, Tim. Welcome to TSDN!

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.

Do you get a line number with the error?

Try alert()ing the name of each element until you get the error:
Expand|Select|Wrap|Line Numbers
  1. for (i=0; i<theForm.elements.length; i++){
  2.     alert(theForm.elements[i].nodeName);
  3.  
Aug 9 '07 #2

Post your reply

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

By using this site, you agree to our Privacy Policy and Terms of Use.