javascript将var传递给php

时间:2010-07-28 10:01:28

标签: javascript

是否可以将var reason的内容传递给action = report?

function redirectConfirm(url)
{

var msg = "Are you sure?";
var reason = prompt("Reason");

if (confirm(msg))
{
    location.href=url;
}
}

并链接

<a onClick="javascript:redirectConfirm('thread.php?id=$id&action=report');">Report post</a>

1 个答案:

答案 0 :(得分:0)

您可以将其作为查询字符串传递:

location.href=url + '&reason='  + reason;

稍后在PHP中,您可以通过$_GET

获取它
$_GET['reason'];