在我的表单中,我试图将无线电检查值传递到下一页(这是一个FPDF页面) 我有4个选项:年假,病假,商务假期,&也其他人与文本框。传递单选按钮
不过,我已经尝试了很多的“如果”和“开关的情况下” 我越来越要么只用值“1” 否则元素“未定义指数:RAD在d:\ XAMPP \ htdocs中\ Application \ generate_report.php on line 13'
有些地方我错了,谁能帮助我。我的代码如下。
HTML表单:
<form id="formmain" method="post" action="generate_report.php" onsubmit="return_validate()">
<script type="text/javascript">
function selectRadio(n){
document.forms["form4"]["r1"][n].checked=true
}
</script>
<table width="689">
<tr>
<td width="500d">
<input type="radio" name="rad" value="0" />
<label>Business Trip</label>
<input type="radio" name="rad" value="1"/><label>Annual Leave</label>
<input type="radio" name="rad" value="2"/><label>Sick Leave</label>
<input type="radio" name="rad" value="3"/><label>Others</label> <input type="text" name="others" size="25" onclick="selectRadio(3)" />
</td>
</tr>
</table>
//....
//below submit button is end of the html page:
<input type="submit" name="submit" value="send" />
</form>
生成PDF格式:
$radio = $_POST['rad']; // I am storing variable
if($radio = 0) {
$type = 'Business Leave';
}elseif ($radio = 1) {
$type = 'Annual Leave';
}elseif ($radio = 2) {
$type = 'Sick Leave';
} else { $type = $_POST['others']; }
//echo
$pdf->Cell(98,10, 'Reason | ' .$type , 1, 0, 'C', $fill);
我试过给了我一个意外的文件结尾的错误,并显示关闭php标签的错误。我不知道是不是因为我犯了错误'{' – sajeesh
完美我完成了,并找到完美的工作,并得到了我想要的。我犯的错是pdf->格在'if'之外 – sajeesh
很高兴听到:) – aksu