my dog learned polymorphism*
The moose likes HTML, CSS and JavaScript and the fly likes HTML FORM tag Query?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "HTML FORM tag Query??" Watch "HTML FORM tag Query??" New topic

HTML FORM tag Query??

Jignesh Gohel
Ranch Hand

Joined: Dec 28, 2004
Posts: 276

In my JSP page i've used a FORM tag.In that I've a textfield & a submit button.Now using its "OnSubmit" attribute I want to call a Javascript function & from that javascript function i want to call a URL.So is it possible???

If it is then how to do it, else I would like to get some suggestions from ur side for other options.

Thanking you,


The Art Of Life Is To Know When To Be Useless And When To Be Useful - CHUANG TZU
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15376
what does this url do?
Jignesh Gohel
Ranch Hand

Joined: Dec 28, 2004
Posts: 276
Hello sir thanks for the reply.

Actually i want to call a servlet using that URL.
vjy chin
Ranch Hand

Joined: Feb 17, 2005
Posts: 279
You can use onClick to call the javascript function and from javascript give the action url to the servlet.

like in the form you have to give

<img type = "image" src="/subscribe.gif" width="78" height="30" onClick(Should write only onClick)= "javaScriptFunctionName()"> </td>

Then you write the javascript function as

document.formname.action = "servletpath and name should come here";

Hope this helps
Jignesh Gohel
Ranch Hand

Joined: Dec 28, 2004
Posts: 276

Thanks for the reply.

Actually from the FORM tag's action attribute i want to call the same(ie in which my form is made) page continuosly while simultaneously call an URL for a servlet using javascript.So is it possible???

If yes then how to approach.Else please provide me some alternatives for doin this.

Waiting for ur reply.
Waez Ali
Ranch Hand

Joined: Jan 24, 2005
Posts: 43
I think you want to first call some page within javascript function after that you want to call page from action attribute of form tag.
Isn't it?

Well if it is so then I think its not possible bkz when you call some page
inside javascript function you have to call it using

document.formname.action ="";statement

as already mentioned by chin,so when you do it you are actually submitting the form & once u r done then don't think that control gets back to ur current page again (unless u call it from the called page)& will perform another submit for you inside form tag.

May be this could help you

If u want to have some page in your current page & after that you want to call some other page then you can use <jsp:include>



Waez Ali
I agree. Here's the link:
subject: HTML FORM tag Query??
Similar Threads
How to pass JSP resultant data to javascript?
Calling Javascript function from Java Code
How to include YUI Widgets with in Flex APplication ??
Retrieve proper form object
Calling a Servlet (Urgent)