我在這裏有大量的單選按鈕,它們的值取自數據庫。我想添加這種類型的假期,但我無法弄清楚。爲了讓自己更加清楚,一旦單擊「生病」單選按鈕並按下提交按鈕,「生病」信用或病假的可用時間(單選按鈕的值(值爲$ sLeave)並在同一時間,這是病假(隱藏式)休假的類型將被傳遞到下一個頁面單擊時是否可以從1個單選按鈕傳遞兩個(2)值?
我想這一個在所有類型的休假:
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可能會解決這個問題,但我希望能有另一種解決方案。
當您將元素標記爲禁用時,該元素不會成爲發佈數據的一部分。 – 2012-07-18 03:28:21
感謝@Rajan的迴應。單選按鈕將僅在特定休假類型的信用降至0後才被禁用。 – Jordan 2012-07-18 03:59:01