我想从我所在的对象中检索我的id和类型。php中的变量会话
然后,在一类我做的:
$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 = undefined & refId = undefined
有人可以帮我吗?谢谢 !
PHP是服务器端,JS是客户端。您无法从客户端访问服务器端变量,因此refType和refId未在您的JS代码中设置。 – Hokascha
哦好吧...我怎么能检索我的refId和refType呢? ... :( – krowry
我认为''document.getElementByID('refType').val()'代替'refType'会让你。这是一个JS问题,但不是PHP。或者如果你有jquery'$ ('#refType).val()'。 – chris85