Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Pass QueryString in window.location.href?

Tags:

javascript

I have written the following javascript function

function getval(sel)
 {
    window.location.href = "Posts?Category=<%= sel %>";
 }

but the value of sel variable is not considered in querystring..

Instead of it, it takes value like following.

...../Post/Posts?Category=%3C%=%20sel%20%%3E

Can anyone help me???

like image 980
Abhay Andhariya Avatar asked Jun 04 '26 23:06

Abhay Andhariya


1 Answers

Because javascript does not understands jsp scriptlet,

Try,

window.location.href = "Posts?Category=" + sel;
like image 130
commit Avatar answered Jun 06 '26 13:06

commit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!