Passing variable to the new popup window

岁酱吖の 提交于 2020-01-06 07:26:27

问题


I have a table in which there are small href links assigned in each row which i have set using below code working fine:

<a href="popup.php" onclick="javascript:void window.open('popup.php','1361166642895','width=700,height=500,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=0,left=0,top=0');return false;"><h10>(check status)</h10></a>

Now I do not want to display the same above href link as static but want to send my variable value to the pop window and need to get data displayed separately for each row. In short i want to pass my variable $name in the popup window. I am trying below code but but isn't happening. Even i tried <FORM> by GET

<?php echo "<a href=popup.php?id=",$name,"><h10>(check status)</h10></a>";?>

On popup.php page:

<?php echo $id = $_GET["id"]; ?>

What i want want is to pass variable using any method (GET or HREF), and it should open in new popup window not in next tab or forwarded window


回答1:


change this

 <?php echo "<a href=popup.php?id=",$name,"><h10>(check status)</h10></a>";?>

to

<?php echo "<a target='_blank' href='popup.php?id=".$name."' onclick=\"window.open(this.href, 'popupwindow', width=400,height=300,scrollbars,resizable');return false;\"><h10>(check status)</h10></a>";?>
                                    ^              ^     ^ ^// here was the mistake

You have not concatenated the strings properly and you missed ' for herf attribute.

Use target="_blank" for opening link in new tab or new browser.



来源:https://stackoverflow.com/questions/14972720/passing-variable-to-the-new-popup-window

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!