这是我的id号列,其值为
<td>ID NUMBER:</td>
<td><input type="hidden" name="txtEmpID" value="<?php echo $this->getArr['id']?>">
<input type="text" <?php echo (isset($this->postArr['EditMode']) && $this->postArr['EditMode']=='1') ? '' : 'disabled'?> name="txtEmployeeId2" value="<?php echo (isset($this->postArr['txtEmployeeId']))?$this->postArr['txtEmployeeId']:$edit[0][5]?>" maxlength="50">
如何将值从列txtEmpID
传递到另一个页面(reset.php)并在reset.php中显示值
这是reset.php
<tr>
<td align="right">Employee ID </td>
<td align="left"><input name="staffid" type="text" class="textfield_login"
value="how to display the value from 1st page into here?"/></td>
</tr>
请帮助我
答案 0 :(得分:2)
将表单中的元素换行并将表单发布到页面。然后,如果您的方法发布,则可以通过$_POST
访问发布数据,如果表单中的方法是get,则可以$_GET
。
<form method="post" action="reset.php">
<td>ID NUMBER:</td>
<td><input type="hidden" name="txtEmpID" value="<?php echo $this->getArr['id']?>">
<input type="text" <?php echo (isset($this->postArr['EditMode']) && $this->postArr['EditMode']=='1') ? '' : 'disabled'?> name="txtEmployeeId2" value="<?php echo (isset($this->postArr['txtEmployeeId']))?$this->postArr['txtEmployeeId']:$edit[0][5]?>" maxlength="50">
</td>
</form>
在reset.php中
echo $_POST['txtEmpID'];//Will contain the value of txtEmpID
答案 1 :(得分:1)
我可以通过两种方式来做到这一点。
<form action="reset.php" method="get">
<input type="text" id="txtEmployeeId2" <?php echo (isset($this->postArr['EditMode']) && $this->postArr['EditMode']=='1') ? '' : 'disabled'?> name="txtEmployeeId2" value="<?php echo (isset($this->postArr['txtEmployeeId']))?$this->postArr['txtEmployeeId']:$edit[0][5]?>" maxlength="50">
<input type="submit" value="Submit">
</form>
是使用Javascript / jQuery获取值并将其作为等效的GET请求传递给URL。
但是,您需要某种触发器来调用javascript函数,例如按钮。
<button onclick="sendValue()">Submit</button>
<script type="text/javascript">
function sendValue()
{
parent.location = 'reset.php?txtEmployeeId2='+document.getElementById("txtEmployeeId2").value;
}
请注意,这需要您将ID属性添加到文本框中。
对于这两种解决方案,您只需更改reset.php文件中的行:
这假设输入的name属性和ID属性都相同。将“txtEmployeeId2”替换为您要为文本框输入提供的任何名称或ID。
<input name="staffid" type="text" class="textfield_login" value="how to display the value from 1st page into here?"/>
要
<input name="staffid" type="text" class="textfield_login" value="<?php echo $_GET["txtEmployeeId2"];?>"/>
答案 2 :(得分:1)
您也可以使用会话。 ($_SESSION
超全局数组)