我这里有大量的单选按钮,它们的值取自数据库。我想添加休假类型,但我无法弄清楚。为了让自己更清楚,一旦单击“病假”单选按钮并按下提交按钮时,“病假”信用或病假的可用时间(我的单选按钮的值是(值 = $ sLeave)同时,将病假(隐藏类型)的休假类型传递到下一页。
我在每种类型的假期中都尝试过这个:
if($sLeave!=0)
{
?>
<input type="radio" name="optLeave" value="<?php echo $sLeave; ?>" onclick="disableTextarea()" /><label for="Sick">Sick</label>
<input type="hidden" name"leaveType" value="Sick" />
<?php
}
else
{
?>
<input type="radio" name="optLeave" disabled="disabled" /><label for="Sick">Sick</label>
<?php
}
?>
但是所有的休假类型都将传递到下一页并输出最后一个隐藏值。不是被选中的那个。
这是代码:
<form id="leaveForm" name="lform" method="get" action="leaveFiled.php" />
if($sLeave!=0)
{
?>
<input type="radio" name="optLeave" value="<?php echo $sLeave; ?>" onclick="disableTextarea()" /><label for="Sick">Sick</label>
<?php
}
else
{
?>
<input type="radio" name="optLeave" disabled="disabled" /><label for="Sick">Sick</label>
<?php
}
?>
<?php
if($vLeave!=0)
{
?>
<input type="radio" name="optLeave" value="<?php echo $vLeave; ?>" onclick="disableTextarea()" /><label for="Vacation">Vacation</label>
<?php
}
else
{
?>
<input type="radio" name="optLeave" disabled="disabled" /><label for="Vacation">Vacation</label>
<?php
}
?>
<?php
if($eLeave!=0)
{
?>
<input type="radio" name="optLeave" value="<?php echo $eLeave; ?>" onclick="disableTextarea()" /><label for="Emergency">Emergency</label>
<?php
}
else
{
?>
<input type="radio" name="optLeave" disabled="disabled" /><label for="Emergency">Emergency</label>
<?php
}
?>
<?php
if($mLeave!=0 && $sex=='F')
{
?>
<input type="radio" name="optLeave" value="<?php echo $mLeave; ?>" onclick="disableTextarea()" /><label for="Maternity">Maternity</label>
<?php
}
else
{
?>
<input type="radio" name="optLeave" disabled="disabled" /><label for="Maternity">Maternity</label>
<?php
}
?>
<?php
if($pLeave!=0 && $sex=='M')
{
?>
<input type="radio" name="optLeave" value="<?php echo $pLeave; ?>" onclick="disableTextarea()" /><label for="Paternity">Paternity</label>
<?php
}
else
{
?>
<input type="radio" name="optLeave" disabled="disabled" /><label for="Paternity">Paternity</label>
<?php
}
?>
<?php
if($uLeave!=0)
{
?>
<input type="radio" name="optLeave" value="<?php echo $uLeave; ?>" onclick="disableTextarea()" /><label for="Union">Union</label>
<?php
}
else
{
?>
<input type="radio" name="optLeave" disabled="disabled" /><label for="Union">Union</label>
<?php
}
?>
<?php
if($oLeave!=0)
{
?>
<tr>
<td height="40" colspan="3" align="left">
<strong>
<input type="radio" name="optLeave" value="<?php echo $oLeave; ?>" onclick="enableTextarea()" />
<label for="Other Leave">Other Leave</label>
<label for="Reason of Leave">Reason of Leave:</label>
<input type="text" name="reasonLeave" size="35" disabled="disabled" />
</strong>
</td>
</tr>
<?php
}
else
{
?>
<tr>
<td height="40" colspan="3" align="left">
<strong>
<input type="radio" name="optLeave" disabled="disabled" />
<label for="Other Leave">Other Leave</label>
</strong>
</td>
</tr>
<?php
}
?>
也许使用 javascript 可以解决这个问题,但我希望有另一种解决方案。