我有几个测试。它们处于启用位置或禁用位置。所以最初我从数据库获取值并适当地设置属性。
if($lr['Test1']=="201")
{
echo "<tr><td>Test 1</td><td><input type='radio' name='Test1' value='enable' > Enable <input type='radio' name='Test1' checked='checked' value='disable' > Disable </td> <td><input type='submit' name='Test' value='Submit'> </td></tr>";
}
else
{
echo "<tr><td>Test 1</td><td><input type='radio' checked='checked' name='Test1' value='enable' > Enable <input type='radio' name='Test1' value='disable' > Disable </td><td><input type='submit' name='Test' value='Submit'> </td></tr>";
}
if($lr['Test2']=="201")
{
echo "<tr><td>Test 2</td><td><input type='radio' name='Test2' value='enable' > Enable <input type='radio' checked='checked' name='Test2' value='disable' > Disable </td><td><input type='submit' name='Test' value='Submit'> </td></tr>";
}
else
{
echo "<tr><td>Test 2</td><td><input type='radio' checked='checked' name='Test2' value='enable' > Enable <input type='radio' name='Test2' value='disable' > Disable </td><td><input type='submit' name='Test' value='Submit'> </td></tr>";
}
if($lr['Test3']=="201")
{
echo "<tr><td>Test 3</td><td><input type='radio' name='Test3' value='enable' > Enable <input type='radio' checked='checked' name='Test3' value='disable' > Disable </td><td><input type='submit' name='Test' value='Submit'> </td></tr>";
}
else
{
echo "<tr><td>Test 3</td><td><input checked='checked' type='radio' name='Test3' value='enable' > Enable <input type='radio' name='Test3' value='disable' > Disable </td><td><input type='submit' name='Test' value='Submit'> </td></tr>";
}
if($lr['Test4']=="201")
{
echo "<tr><td>Test 4</td><td><input type='radio' name='Test4' value='enable' > Enable <input type='radio' checked='checked' name='Test4' value='disable' > Disable </td><td><input type='submit' name='Test' value='Submit'> </td></tr>";
}
else
{
echo "<tr><td>Test 4</td><td><input checked='checked' type='radio' name='Test4' value='enable' > Enable <input type='radio' name='Test4' value='disable' > Disable </td><td><input type='submit' name='Test' value='Submit'> </td></tr>";
}
一切都很好。但即使用户将测试从启用更改为禁用,我也会获得相同的旧值,即启用。即
$_POST['Test1'] is enable even when the user clicked disable radio button.
请帮帮我。
答案 0 :(得分:0)
我在表单中加入了它们,因为它们有不同的提交值并添加了方法=查看它在网址中返回的内容!并且它返回了正确的值。试试这种方式可能会有所帮助
<form name="test" method="GET">
<tr>
<td>Test 1</td>
<td><input type='radio' name='Test1' value='enable' > Enable
<input type='radio' name='Test1' checked='checked' value='disable' > Disable
</td>
<td><input type='submit' name='Test' value='Submit'> </td>
</tr>
</form>