我有一个表格,像这样:
echo '<table align=center border=1>';
echo '<form method="post">';
echo '<tr>';
echo '<th>Lista Echipamente</th>';
echo '<th>Actiune</th>';
echo '</tr>';
while($row=MysqL_fetch_array($sql)){
echo '<tr>';
echo '<td><input class="search-logi" id="tip" type="text" name="tip" value="'.$row['tip'].'"></td>';
echo '<td><input type=submit name=modifica value=Modifica></td>';
echo '</tr>';
}
echo '</form>';
echo '</table>';
由于循环,此表单将具有多行.对于每个输入,将是一个按钮. 假设我想在第二个输入中添加一个值,然后我将提交它(显然也是第二个按钮).问题就出现了,在我的代码中我只有一个按钮,但是用户看到的循环次数和循环次数一样多.如何查看提交的按钮? 解决方法: 或者,您可以使用< button>用于此目的的标签:
echo '<form method="post">'; // form tags are outside to be valid!!!
echo '<table align=center border=1>';
echo '<tr>';
echo '<th>Lista Echipamente</th>';
echo '<th>Actiune</th>';
echo '</tr>';
while($row = MysqL_fetch_assoc($sql)){
echo '<tr>';
echo '<td><input class="search-logi" type="text" name="tip['.$row['id'].']" value="'.$row['tip'].'"></td>';
echo '<td><button type="submit" name="modifica" value="'.$row['id'].'">Modifica</button</td>';
echo '</tr>';
}
echo '</table>';
echo '</form>';
然后在处理表格上:
$modifica = $_POST['modifica']; // shoud return the index num
$tip = $_POST['tip'][$modifica]; // select which textBox
(编辑:北几岛)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|