I am trying to create a dynamic hyperlink using JavaScript. I am using "&" to pass multiple arguments, but ii am getting a parsing error.
JavaScript:
<script>
function visitPage() {
var phn = document.getElementById("bid").value;
var totalprice = spans[3].innerHTML;
window.location.href = 'https://www.instamojo.com/stayuncle/payments-for-stayuncle?data_amount='
+ totalprice + '&' + 'data_Field_68092=' + phn;
}
</script>
Error:
The entity name must immediately follow the '&' in the entity reference.
I tried to fix it by passing '&'
, which resulted in the link looking like this:
https://www.instamojo.com/stayuncle/payments-for-stayuncle/?data_amount=1374.75&data_Field_68092=Hotel%20Delhi%20Airport%20Link
'&' is still in link, instead of getting converted to an ampersand itself.
I have also removed the semicolon (;
) after every &
, because it didn't let me post actual problem.