【问题标题】:On submit echo td dropdowns and ad new td在提交 echo td 下拉列表并添加新的 td
【发布时间】:2011-04-18 14:46:01
【问题描述】:

我有以下代码:

<form action="" method="POST">
<?php
$count = isset($_POST['count']) ? $_POST['count'] : 1;
if($count > 11) $count = 11;
?>

<table>
<!-- Keeps track of the current number of rows -->
<input type="hidden" name="count" value="<?php echo $count+1; ?>"/>

<?php for($i = 0; $i < $count; $i++): 
// Loop through all rows gathering the data here, and then creating the fields below

$val0 = isset($_POST['field'][$i]['0']) ? $_POST['field'][$i]['0'] : '';
$val1 = isset($_POST['field'][$i]['1']) ? $_POST['field'][$i]['1'] : '';
$val2 = isset($_POST['field'][$i]['2']) ? $_POST['field'][$i]['2'] : '';
?>
<tr>

<td><input name="field[<?php echo $i; ?>][0]" value="<?php echo $val0; ?>"/></td>
<td><input name="field[<?php echo $i; ?>][1]" value="<?php echo $val1; ?>"/></td>
<td><input name="field[<?php echo $i; ?>][2]" value="<?php echo $val2; ?>"/></td>
</tr>
<?php endfor; ?>

</table>

<input type="submit" value="click me" />

如何将字段设置为下拉菜单,当您按下提交时,将下拉菜单作为文本而不是作为下拉菜单回显?

【问题讨论】:

标签: php drop-down-menu html-table


【解决方案1】:

首先:填写以下内容:

  1. 将此设置为 action="mytestpage.php"
  2. 为其命名属性,例如:name="send"
  3. 将这些字段类型指定为:type="Text"

如果您想要下拉菜单,请结合使用 &lt;select&gt;&lt;option&gt;...

这是学习方法的开始:
http://www.echoecho.com/htmlforms11.htm

要打印结果,请执行以下操作:

if(isset($_POST['send'])
{
    print($_POST['youroptionname']);
}

希望对你有帮助。

【讨论】:

  • 你认为你可以把它放到我的代码中吗?我知道如何做下拉和打印我只是不知道把它放在哪里?
  • 我不能在你的代码中放任何东西,你应该这样做。如果您将我的答案的 if(isset($...} 部分放在
    外侧的代码中,它应该可以工作。只要确保所有名称都正确。
猜你喜欢
  • 2011-08-07
  • 2021-08-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-04-04
  • 2015-06-15
  • 2017-08-05
  • 1970-01-01
相关资源
最近更新 更多