Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTML FORM tag Query??

 
Jignesh Gohel
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

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,
Jignesh
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what does this url do?
 
Jignesh Gohel
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello sir thanks for the reply.

Actually i want to call a servlet using that URL.
 
vjy chin
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

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.
Jignesh
 
Waez Ali
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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>

thanks

Regards

Waez Ali
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic