I want to pass $_GET
value to window.open
, but how?
My current code can't pass $_GET
value:
function googlemap() {
ver id = <? php print ''.$_GET['buid'].''; ?>
window.open("Views/Admin/addresstomap.php?bid=+id", "myWindow",
"status = 0, height = 600, width = 800, resizable = 0 top=200, left=300,scrollbars=no,toolbar=no, location=no, directories=no, ")
}
You're not using the variable in the window.open
call, you're just using a string with the name of the variable:
"Views/Admin/addresstomap.php?bid=+id"
JavaScript won't interpret id
from that string. You need to separate it from the string itself:
"Views/Admin/addresstomap.php?bid=" + id
Additionally, you have a typo in the var
keyword and you're missing a semi-colon. This:
ver id=<?php print''.$_GET['buid'].''; ?>
should be this:
var id=<?php print''.$_GET['buid'].''; ?>;
Indeed, you may even need quotes around it if the variable is supposed to be a string. (I don't know if it is, but you should be able to figure it out.) In that case the line would be:
var id="<?php print''.$_GET['buid'].''; ?>";
(Note: Given these errors, there may still be others that I haven't noticed. You'll want to do some debugging, check your PHP logs, check your JavaScript console, etc.)