我有两个PHP页面a.php b.php
其中a.php中有个控件 <input type="hidden" name="ab_0" id="ab_0" value="" />
b.php中<?php
echo"<script>parent.document.getElementById('ab_0').value ='abc';</script>";
?>
我现在想在a.php页中获取控件ab_0的value
我用$_["ab_0"]获取的值却为空。请大家看下,应该怎么样在a.php中获取控件ab_0的value=“abc”呢
其中a.php中有个控件 <input type="hidden" name="ab_0" id="ab_0" value="" />
b.php中<?php
echo"<script>parent.document.getElementById('ab_0').value ='abc';</script>";
?>
我现在想在a.php页中获取控件ab_0的value
我用$_["ab_0"]获取的值却为空。请大家看下,应该怎么样在a.php中获取控件ab_0的value=“abc”呢
如果是GET的method,那么b.php的写法就是 $_GET['ab_0'],如果method是POST,那么就是 $_POST['ab_0']。
{
$ab_0 = "abc";
}希望沒理解錯樓主的意思
<form action="?a=b" method="post">
<input type="hidden" name="ab_0" id="ab_0" value="" />
<iframe src="Upimg.php" marginheight="0" marginwidth="0" scrolling="no" width="400" height="30" frameborder="0"></iframe>
<input type="submit" value="提交"/>
</form>
<?php
if($_REQUEST["a"]=="b")
{
echo $_POST["ab_0"];
}
?>
b.php的代码是:
<?php
if($_REQUEST["action"]=="upimg")
{
$upfile=$_FILES['imagename'];
$name1=$upfile['name'];
echo"<script>parent.document.getElementById('ab_0').value ='".$name1."';</script>"};
?>
<form action="?action=upimg" method="post" enctype="multipart/form-data">
<input type="file" name="imagename" />
<input type="submit" value="提交"/>
再应该看得清楚了吧。
<form action="?a=b" method="post">
<input type="hidden" name="ab_0" id="ab_0" value="" />
<iframe src="Upimg.php" marginheight="0" marginwidth="0" scrolling="no" width="400" height="30" frameborder="0"></iframe>
<input type="submit" value="提交"/>
</form>
<?php
if($_REQUEST["a"]=="b")
{
echo $_POST["ab_0"];
}
?>
b.php的代码是:
<?php
if($_REQUEST["action"]=="upimg")
{
$upfile=$_FILES['imagename'];
$name1=$upfile['name'];
echo"<script>parent.document.getElementById('ab_0').value ='".$name1."';</script>"};
?>
<form action="?action=upimg" method="post" enctype="multipart/form-data">
<input type="file" name="imagename" />
<input type="submit" value="提交"/>现在,在a.php页面中 echo $_POST["ab_0"]输出的值为什么为空?
当然是空的了,因为你<input type="hidden" name="ab_0" id="ab_0" value="" />他的value都是空的。
另外a.php 和b.php 两个页面有什么关联
不知道你从哪里抄过来的代码啊。iframe 是不能写到form下级的。