Kevin Davis
Kevin Davis

Reputation: 365

mpdf showing a radio button and checkbox selected

I have a quick question.

I creating an pdf output when the user clicks on the button. However the problem I'm having is the radio and checkbox. I tried to use the standard
($answer == 'What the value is' ) ? 'checked':''

however when it is outputted to a pdf, it doesn't show the radio button or checkbox selected. Is there way I can have the radio buttons or checkbox's selected in an pdf output?

Thank you

Upvotes: 0

Views: 3922

Answers (3)

Shahjalal Shaju
Shahjalal Shaju

Reputation: 1

<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

Its Work for me

Upvotes: 0

Kevin Davis
Kevin Davis

Reputation: 365

Ok, I have found a solution. What I did was I put the the checkbox and radio button in if statement and I did put the code in the following format:

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

That did the trick..

Upvotes: 3

NormundsP
NormundsP

Reputation: 413

try this:

if ($answer = "1"){

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

Where is 1 true. I assume that, you get these values from db. In this cycle check these values if it checked.

Upvotes: 1

Related Questions