Reputation: 1194
I have a little bit of javascript code that is getting some parameters from php. the php variable $rid is an integer with a value within 1-100. what i am trying to do is change the value of the 'rid' variable in the querystring by a specified amount (offset). when i remove the last str($rid)
characters from window.location.href
, i am left with http://www.qwerty.asdf/uiop?rid=
. When I add <?php echo $rid;?>+offset
to it I get http://www.qwerty.asdf/uiop?rid=2
for example. when I try the code, nothing happens, but I've debugged and str is the desired value by the time I say window.location.href=str;
why doesnt the page redirect? I have tried window.location as opposed to window.location.href, but it doesn't work.
p.s. there is no other javascript on the page
function moveRid(offset) {
str = window.location.href.substring(0,window.location.href.length-<?php echo strlen($rid);?>);
rid = <?php echo $rid;?>+offset;
str += rid;
window.location.href=str;
}
Upvotes: 2
Views: 384
Reputation: 78006
You need to actually set the window.location
function moveRid(offset) {
str = window.location.href.substring(0,window.location.href.length-<?php echo strlen($rid);?>);
rid = <?php echo $rid;?>+offset;
str += rid;
//window.location.href=str;
window.location = str;
}
Upvotes: 1