php中的变量会话

时间:2017-01-30 14:08:02

标签: javascript session

我想从我所在的对象中检索我的id和类型。

然后,在我做的课上:

$refType = $_REQUEST['refType'];

$refId = $_REQUEST['refId'];

和:

  <input id="refType" name="refType" type="hidden" value="<?php echo ****" />
  <input id="refId" name="refId" type="hidden" value="<?php echo ****;?>" />

当我在js中调用我的页面时,我会这样做:

  url="addNote.php?refType="+refType+"&refId="+refId;
  window.location=url;

但是在我的网址中,当我尝试进入我的页面时,我有:

RefType的未定义=&安培; REFID =未定义

有人可以帮帮我吗?谢谢!

2 个答案:

答案 0 :(得分:1)

尝试使用document.getElementById

url="addNote.php?refType="+document.getElementById('refType').value+"&refId="+document.getElementById('refId').value;
window.location=url;

答案 1 :(得分:-1)

您可以添加以下内容:

<script>
   var refType = <?php echo $refType ?>
   var refId = <?php echo $refId ?>
   var url="addNote.php?refType="+refType+"&refId="+refId;
   window.location=url;
</script>