【发布时间】:2016-10-17 01:50:42
【问题描述】:
我有一个表格:
<form action= "catrand.php" method="POST" name="form">
<h4>How mach text need to print?</h4>
<input type="text" onkeyup="validate(this)" name="inp"> <script> function validate(inp) { inp.value = inp.value.replace(/[^\d,.]*/g, '') .replace(/([,.])[,.]+/g, '$1') .replace(/^[^\d]*(\d+([.,]\d{0,5})?).*$/g, '$1'); } </script>
<h4>Select how print text</h4>
<input type="radio" name="b001" value="First"><font>text</font>
<input type="radio" name="b001" value="Second"><font>check</font>
<input type="radio" name="b001" value="Last"><font>radio</font>
<h4>Input text</h4>
<input type="text" name="inp1">
<input type="text" name="inp2">
<input type="text" name="inp3">
<p><input type="submit"></p>
</form>
和php代码:
for($i=1;$i<=$number;$i++)
{
switch($_POST['b001']) {
case "Last":
{
echo "<input type=\"radio\" onclick=\"uncheck_radio(this)\" value=\"First\" \"name=\"h001\">" .$numberone;
echo "<input type=\"radio\" onclick=\"uncheck_radio(this)\" value=\"Second\" \"name=\"h001\">".$numbertwo;
echo "<input type=\"radio\" onclick=\"uncheck_radio(this)\" value=\"Third\" \"name=\"h001\">".$numberthree."</br>";
break;
}
}
}
但尽管单选按钮的名称相同,但我可以标记两个或更多单选按钮。为什么?我的代码有什么问题?
【问题讨论】:
标签: php html radio-button