my dog learned polymorphism*
The moose likes HTML, CSS and JavaScript and the fly likes Inserting parameters into hyperlink dynamically 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 "Inserting parameters into hyperlink dynamically" Watch "Inserting parameters into hyperlink dynamically" New topic
Author

Inserting parameters into hyperlink dynamically

Rajesh Khan
Ranch Hand

Joined: Oct 16, 2011
Posts: 230
Hi i wanted to know if there was a way to insert content into a hyperlink dynamically. I mean i have something like this in table cell.

but Flink() is a javascript function which has a variable and a value which needs to be appended to the link so the link should like like this in the end

Is there any way in which i could make java script append that value ?? The only way i thing that is possible is to assign it a id. Traverse through the dom and then change the inner text.If i do that I still think it wont work since the link has already been clicked.
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
If the parameters to pass are well defined, one easy approach is to define a form with the parameters you want, then populate the input fields and submit the form via javascript.
Another would be to build up a url in a javascript string (don't forget to escape the necessary values), and then set it via window.location.href
All of that is javascript rather than JSP.

something like this:




 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Inserting parameters into hyperlink dynamically
 
Similar Threads
Dynamic Hyperlink--How to??
Passing value to a servlet through Hyperlink
Passing parameters to the servlet
global veriable + hyper link
Spring data binding to hyperlink