Reputation: 14141
I have some javascript to direct the page to a new url but I get directed to a www.myurl.com/undefined instead.
This is what I have, not sure what is wrong. I have tried also window.location
if (r == true) {
window.location.href = ('http://www.myurl.com/pubs_delete.php?=id'.a_href)
};
Thank you for any pointers
Upvotes: 0
Views: 3371
Reputation: 884
try something like this
var a_href;
if (r == true) {
window.location.href = ('http://www.myurl.com/pubs_delete.php?=id'+a_href)
};
javascript concatenation using +(plus) sympol ,you are using .(dot) sympol that is the problem for u
Upvotes: 1
Reputation: 5476
Combining both answers:
if (r) { // r == true is quite redundat
window.location.href = "http://www.myurl.com/pubs_delete.php?id=" + a_href;
};
Upvotes: 1
Reputation: 123367
Assuming a_href
is a defined variable
...delete.php?id=' + a_href
string concatenation in javascript is +
, not .
and the equal is misplaced
Upvotes: 1
Reputation: 9691
if (r == true) {
window.location.href = 'http://www.myurl.com/pubs_delete.php?id=' + a_href
};
Upvotes: 1