By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,148 Members | 739 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,148 IT Pros & Developers. It's quick & easy.

Javascript - another Object Expected error when executing javascript function

P: 1
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.

Expand|Select|Wrap|Line Numbers
  1. <html-el:form action="${target}" onsubmit="return testTheForm(this)">
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>
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;">
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.


Aug 9 '07 #1
Share this Question
Share on Google+
1 Reply

Expert 5K+
P: 5,821
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);
Aug 9 '07 #2

Post your reply

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