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???
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???
Share Improve this question asked Jul 15, 2013 at 11:23 Abhay AndhariyaAbhay Andhariya 2,1573 gold badges17 silver badges25 bronze badges 4-
1
Because
.js
files are not parsed by your back-end. – Fabrício Matté Commented Jul 15, 2013 at 11:25 -
Do you really need to wrap 'sel' in
<%= %>
? – Ben Gulapa Commented Jul 15, 2013 at 11:27 - possible duplicate of how to pass parameter to javascript in asp – Fabrício Matté Commented Jul 15, 2013 at 11:28
-
Or would you want to use the the function argument
sel
to call a method on the back-end? In that case the principle applied is the same as stackoverflow./q/13840429/1331430 – Fabrício Matté Commented Jul 15, 2013 at 11:33
2 Answers
Reset to default 7Because javascript does not understands jsp scriptlet,
Try,
window.location.href = "Posts?Category=" + sel;
I don't know where you found this <%= sel %>
, but its not the native JavaScript style of doing it. Try this:
function getval(sel)
{
window.location.href = "Posts?Category=" + sel;
}