Pass An Id To Anchor Tag
Solution 1:
You are trying to use &
instead of ?
which will cause an error.
Try this:
<ahref="some_url?userId=123"> something here </a>
Explanation
All i did was change the &
to a ?
.
Remember these two rules:
- You should use the
?
symbol to connect GET values to a url - You should use the
&
symbol to connect GET values to each other
I hope this helped you out, and feel free to ask for further help!
Solution 2:
The parameter you are sending is called userId
and the one you try to retrieve is ID
. You should use var id = getUrlParameters()["userId"]
instead.
EDIT:
If your problem is just passing id
as an argument to the href
, try this:
First, add a tag id to you link tag:
<a href="some_url&userId=id"id="a_tag_id_here">...</a>
Then, add the href
with JQuery, using your id
variable:
$('a_tag_id_here').attr('href','https://sox.host.net:7020/ps/sox/HRS_HRAM.JN_HRS_CE.GBL&userId='+id);
It's up to you to decide what should trigger this command. If you want it to be set right after the loading of the page, just put this code inside this:
$(document).ready(function() {
// code here
});
Solution 3:
Try this,
var getid= /*your id*/
then get the url from anchor tag using .attr('href')
method replace the part after = ,using split('=')
method.
forex:
var temp=$('a').attr('href').split('=')[0];
$('a').attr('href',temp+'='+getid);
Post a Comment for "Pass An Id To Anchor Tag"