• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Javascript function returns document.forms.0 null or not an object error

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using jsp and java script function and calling java script function on onclick property of <a></a> tag but while clicking on link I am getting document.forms.0 null or not an object error.
Please suggest.
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Deepa,

Without looking at your code, its tough to know what's going wrong.
 
Deepa Kulkarni
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Swastik,

I have a main.jsp in which I have included another jsp ,(another.jsp).

Please find the code below.

main.jsp :-

<body>
<div>
<form method="post">
<jsp:include page="/WEB-INF/search/another.jsp"></jsp:include>
</form>
</body>
----------------------------------------------------------------------------

another.jsp :-

<table>
<tr>
<td>
<div>
<a href="#" onclick="submitFunction();">Go</a>
<div>
</td>
</tr>
</table>
----------------------------------------------------------------------------

index.js :-

function submitFunction()
{
document.forms[0].action = "http://www.google.co.in";
document.forms[0].submit();
}

Above submit function throws an error message document.forms.0 is null or not an object.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In which page are you using . I tested your code, works fine.
 
Deepa Kulkarni
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Inside main.jsp the script is added.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then it has to work. Try it once again.

main.jsp
-----------




and a I guess the .js file is in the same folder where main.jsp exist, or else you have to specify the path of js file, and one more thing, next time if you show your code here, please use code tags.
 
Deepa Kulkarni
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sure.Thanks
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic