This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes submit form on click of any hyperlink 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 "submit form on click of any hyperlink" Watch "submit form on click of any hyperlink" New topic
Author

submit form on click of any hyperlink

Neeraj Vij
Ranch Hand

Joined: Nov 25, 2003
Posts: 315
I want to submit a form, on clcik of any of the hyperlink on the page.

is there any way to do it ?

thanks
neeraj
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

add an on click event to all the links and do a form submit in JavaScript. A better question is why you would want to do this.


GenRocket - Experts at Building Test Data
Neeraj Vij
Ranch Hand

Joined: Nov 25, 2003
Posts: 315
is there any short way of doing it there are too many hyperlinks and jsps to do this

I want to carry a value of a parameter to the next page, when a hyperlink is clicked

thanks
Neeraj.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Well you could make your jsp append the qs parameter to the links in the first place.

If JS is disabled, the JavaScript solution is not going to work.

basiclaly you need to add onclick handlers to every link and call document.formName.submit()

Eric
Neeraj Vij
Ranch Hand

Joined: Nov 25, 2003
Posts: 315
Thanks Eric.

I also don't want the value of the variable to be visible in the query string.

thanks
neeraj/
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Then the form should have a method of POST.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: submit form on click of any hyperlink
 
Similar Threads
Hyperlink and submit
Hyper Link
calling servlet through hyperlink click
how to pass an array to hyper link
Saving user enter values in a form