首頁 >後端開發 >php教程 >input 之间怎么传递数据是在同一页面

input 之间怎么传递数据是在同一页面

WBOY
WBOY原創
2016-06-23 13:43:341032瀏覽

input 之间怎么传递数据是在同一页面
怎么把pripath和tfilename2 的数据 传给tfilename      就一个页面

页面提交后tfilename    值得到    pripath和tfilename2 的数据

        <input name="tfilename" type="hidden" id="tfilename" value="<?=$pripath?><?=$tfilename2?>">           <td height="25" bgcolor="#FFFFFF">根目录</td>	  <input name="pripath" type="text" id="pripath" value="<?=$pripath?>" size="30">      <input name="tfilename2" type="text" id="tfilename2" value="<?=$tfilename2?>" size="16">


回复讨论(解决方案)

<script type="text/javascript">function add(){	document.getElementById('tfilename').value = document.getElementById('pripath').value + '' + document.getElementById('tfilename2').value;}</script><input name="tfilename" type="hidden" id="tfilename" value="<?=$pripath?><?=$tfilename2?>">     <td height="25" bgcolor="#FFFFFF">根目录</td><input name="pripath" type="text" id="pripath" value="<?=$pripath?>" size="30"><input name="tfilename2" type="text" id="tfilename2" value="<?=$tfilename2?>" size="16"><input type="button" name="b1" onclick="add()" value="传递" >


点传递按钮。

哦哦哦噢噢噢噢

PHP可以实现吗

<?phpheader("Content-type: text/html; charset=utf-8");$pripath = "c:\\windows\\";$tfilename2 = "test.txt";?><form action="" method="post" name="file_form" id="file_form"/><table>    <tr> <input name="tfilename" type="hidden" id="tfilename" value="<?php echo $pripath; ?><?php echo $tfilename2;  ?>" />           <td height="25" bgcolor="#FFFFFF">根目录</td>      <input name="pripath" type="text" id="pripath" value="<?php echo $pripath; ?>" size="30">      <input name="tfilename2" type="text" id="tfilename2" value="<?php echo $tfilename2; ?>" size="16">      </tr>      <tr>          <td><input type="submit" name="submit"/></td>      </tr></table></form><?phpif (isset($_POST['submit'])) {    $pripath = $_POST['pripath'];    $pripath = (!get_magic_quotes_gpc()) ? addslashes($pripath) : $pripath;    $tfilename2 = $_POST['tfilename2'];    $tfilename2 = (!get_magic_quotes_gpc()) ? addslashes($tfilename2) : $tfilename2;    $str = "<script>\r\n";    $str .= "document.getElementById('tfilename').value = '{$pripath}{$tfilename2}';\r\n";    $str .= "document.getElementById('pripath').value = '{$pripath}';\r\n";    $str .= "document.getElementById('tfilename2').value = '{$tfilename2}';\r\n";    $str .=  "</script>\r\n";        echo $str;}?>

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn