473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 2598
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

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

Similar topics

0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.