This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Inserting parameters into hyperlink dynamically" Watch "Inserting parameters into hyperlink dynamically" New topic

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

Joined: Jul 06, 2005
Posts: 1518
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:

I agree. Here's the link:
subject: Inserting parameters into hyperlink dynamically
It's not a secret anymore!