简体   繁体   English

通过open.window传递php变量

[英]Pass php variable though open.window

I'm pretty new to javascript so please excuse this question if it seems pretty nooby. 我对javascript很陌生,所以如果看起来很笨拙,请原谅此问题。 I am writing an online calendar to book engineer's jobs so we need to be able to look at the calendar whilst looking at and editing individual jobs. 我正在写一个在线日历来预定工程师的工作,因此我们需要能够在查看和编辑单个工作的同时查看日历。 After much deliberation I decided the best way to do this is by opening the jobs in a new window using window.open. 经过深思熟虑,我决定最好的方法是使用window.open在新窗口中打开作业。 However, I would like to pass the job id via the url in order to pass it to the new window but for love nor money I can't work it out or find a solution. 但是,我想通过url传递工作ID,以便将其传递到新窗口,但是出于爱或金钱的考虑,我无法解决它或找到解决方案。 Here is my code so far 到目前为止,这是我的代码

function open_win() 
{
    window.open('job_detail.php', '_blank','toolbar=0,location=no,menubar=0,height=400,width=400,left=200, top=300');

}

<a href="#" onclick="open_win()" ><? echo $row['name']; ?></a>

The $row['name'] is the value of the link and the value I want to pass will be held in $row['id'] or $job_id. $ row ['name']是链接的值,我要传递的值将保存在$ row ['id']或$ job_id中。 I just can't work out where to put it so it passes on. 我只是无法弄清楚它的放置位置,因此它可以继续下去。

Any help will be greatly appreciated 任何帮助将不胜感激

As a parameter? 作为参数?

function open_win(id) {
    window.open('job_detail.php?id=' + id, '_blank','toolbar=0,location=no,menubar=0,height=400,width=400,left=200, top=300');
}
<a href="#" onclick="open_win(<?= $row['id'] ?>)"><? echo $row['name']; ?></a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM