I have captured 3 values from a datalist template using JavaScript, now I need to append these values into an existing anchor which is:
<a id="link" href='nextpage.aspx?id=<%#Eval("PlateId")%>&pp= #Eval("price")%>'>
I found the way to get the anchor href from JavaScript:
<script language='javascript' type="text/javascript" >
function addLink() {
var anchor = document.getElementById("link");
anchor.href = anchor + "&qty=";}
</script>
But, I can't add the js value after "&qty="
, I have tried adding the value like this:
anchor.href = anchor +"&qty=+Value+"
And with this:
anchor.href = anchor +"&qty='Value' "
I can't put it out of the quotation marks, because it won't display in the anchor.
anchor.href = anchor + "&qty="
should be
anchor.href = anchor.href + "&qty="
...otherwise you are trying to turn the link element into a string!
Meanwhile, you still need to keep Value
out of the quotation marks, otherwise the final text generated will always be exactly that text: Value
. If Value
is a variable and is not returning the value you expect (an empty or undefined value, for example), then you need to look at the code that declares it and change that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With