• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javascript error: object expected

 
Chris Cornelius
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a dynamic jsp form where I want the user to be able to select and
click on a row and have the click action submit values using javascript. Here is a snippet of my code for the page, the problem I am having is that when the row is clicked, a javascript error of object expected appears. Any
help would be greatly appreciated.

Chris Cornelius

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which line is causing the error?
 
Keith Sebastian
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chris, I looked through the code, and one thing I noticed is you need to call submit() on a form object.

Since you only have one form, you could try:
document.forms[0].submit();

Edit: I notice you named your form "form". Not recommended. If, for example, you named it "myform" then you could reference it:
document.myform.submit();
[ September 27, 2005: Message edited by: Keith Sebastian ]
 
Chris Cornelius
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is on the following line:



I had it set up a different way and called the submitForm1 just fine before, it is when I switched to the above line is where the problem occurs. Plus this is only a part of the page I have other places that are not shown that submit to the submitForm function for navigation purposes.

Thanks again!

Chris
 
Keith Sebastian
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should try looking at the browser source after the page has been rendered. Your jsp code makes it tough to determine what might be the problem.

In the following code:
submitForm1("GOTO_VIEW_ONLY_FORM", <cut value='${item.applicantID}'/>)
What does <cut value='${item.applicantID}'/> evaluate to? If it's not in quotes and doesn't equal a variable on the page, then it probably will fail.
[ September 27, 2005: Message edited by: Keith Sebastian ]
 
Chris Cornelius
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help Keith. I have tried your suggestion of the quotation marks around <c ut value="${item.applicantID}">, but I still get the same error. This object is a long value coming from a servlet that is querying a table in a database. The error I am getting is pretty strange, it says that the error is occurring on a line that is blank.

Chris


[ September 27, 2005: Message edited by: Chris Cornelius ]
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
onclick='submitForm1("GOTO_VIEW_ONLY_FORM", "<c ut value='${item.applicantID}'/>")'
 
Chris Cornelius
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Eric,

I tried that code that you sent and am still getting the error.

Here is the whole code for the page, maybe that will be more
insightful. I really appreciate the help!!



If I put in the following code it will work, but I need the above to work.

 
Chris Cornelius
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to everyone for the help, I seem to have fixed the problem.

I had to replace this:


With this:


I still am not quite sure why this works over what I had, if anyone would like to explain, I am all ears!

Chris
 
Keith Sebastian
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you ever try my suggestion to call document.forms[0].submit() instead of just submit() in your functions?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic