Reputation: 51
My URL is
/home/?tx_besijobs_pi1[pointer]=2&cHash=749431ca0340bf2344cc90704f79570f
My jquery code contain
var pntr = getUrlVars()["tx_besijobs_pi1[pointer]"];
from which I am getting pointer value as 1,2,3,...
I have to change pointer value to 0 on next Tab click. My replace code looks like
id =id.replace("[pointer]=pntr", "[pointer]=0");
But its not working...
If I am manually giving pointer value
id =id.replace("[pointer]=2", "[pointer]=0");
the code will work . How can use "pntr" in the code?
Upvotes: 0
Views: 126
Reputation: 7129
pntr
is a variable, so it should be outside the quotation marks.
Try this:
id = id.replace("[pointer]=" + pntr, "[pointer]=0");
Upvotes: 1
Reputation: 4666
use regular expression like:
var url = '/home/?tx_besijobs_pi1[pointer]=2&cHash=749431ca0340bf2344cc90704f79570f';
alert( url.replace(/pointer\]=\d{1,}/gi, "pointer]=0"));
Upvotes: 0