• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

javascript error: object expected

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Sheriff
Posts: 67556
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which line is causing the error?
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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", <c:out value='${item.applicantID}'/>)
What does <c:out 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you ever try my suggestion to call document.forms[0].submit() instead of just submit() in your functions?
 
My name is Inigo Montoya, you killed my father, prepare to read a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic