aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes javascript error: object expected Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "javascript error: object expected" Watch "javascript error: object expected" New topic
Author

javascript error: object expected

Chris Cornelius
Ranch Hand

Joined: Aug 02, 2005
Posts: 48
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

Joined: Jan 10, 2002
Posts: 61413
    
  67

Which line is causing the error?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Keith Sebastian
Greenhorn

Joined: Mar 10, 2005
Posts: 9
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

Joined: Aug 02, 2005
Posts: 48
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

Joined: Mar 10, 2005
Posts: 9
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

Joined: Aug 02, 2005
Posts: 48
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
onclick='submitForm1("GOTO_VIEW_ONLY_FORM", "<c ut value='${item.applicantID}'/>")'
Chris Cornelius
Ranch Hand

Joined: Aug 02, 2005
Posts: 48
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

Joined: Aug 02, 2005
Posts: 48
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

Joined: Mar 10, 2005
Posts: 9
Did you ever try my suggestion to call document.forms[0].submit() instead of just submit() in your functions?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javascript error: object expected