mpdf 显示选中的单选按钮和复选框

mpdf showing a radio button and checkbox selected

我有一个简单的问题。

我在用户单击按钮时创建 pdf 输出。但是我遇到的问题是收音机和复选框。我尝试使用标准
($answer == 'What the value is' ) ? 'checked':''

然而,当它输出为 pdf 时,它不显示选中的单选按钮或复选框。有什么办法可以在 pdf 输出中选中单选按钮或复选框?

谢谢

试试这个:

if ($answer = "1"){

 $output .= 'Yes <input type="checkbox" checked /> ';
}
else{
 $output .= 'Yes <input type="checkbox" /> ';
}

其中 1 为真。我假设,您从 db 获得这些值。在此循环中检查这些值(如果已检查)。

好的,我找到了解决办法。我所做的是将复选框和单选按钮放入 if 语句中,并将代码按以下格式放置:

<input type="radio" checked="checked"> Yes

成功了..

<input type="radio" value="1" <?php $data->input_11 == 1 ? 'checked="checked"' : null ?> > Yes

<input type="checkbox" value="1" <?php $data->input_11 == 1 ? 'checked="checked"' : null ?> > Yes

对我有用