Welcome Guest, Not a member yet? Register   Sign In
Form check boxes
#1

[eluser]Todlerone[/eluser]
Hello everyone and thank-you in advance. I have a form that submits to the database as planned. What I'm trying to do is allow for editing of the information after submitted. The problem I'm having is setting the conditions of my check boxes to what was originally set. My code seems to always set No. I can see why it does it, just not sure how to correct it.
Code:
<label for="ReferralImaging">Referral Imaging:</label>
                        &lt;?php if ($pt['Referral_ct'] == 'Yes'){ ?&gt;
                                &lt;?php echo "&lt;input type=\"checkbox\" name=\"Referral_ct\" value=\"Yes\" checked /&gt;CT";?&gt;
                            &lt;?php }else{ ?&gt;
                                &lt;?php echo "&lt;input type=\"checkbox\" name=\"Referral_ct\" value=\"No\" /&gt;CT";}?&gt;

                        &lt;?php if ($pt['Referral_mri'] == 'Yes'){ ?&gt;
                                &lt;?php echo "&lt;input type=\"checkbox\" name=\"Referral_mri\" value=\"Yes\" checked /&gt;MRI";?&gt;
                            &lt;?php }else{ ?&gt;
                                &lt;?php echo "&lt;input type=\"checkbox\" name=\"Referral_mri\" value=\"No\" /&gt;MRI";}?&gt;    

                    &lt;?php if ($pt['Referral_mrisrs'] == 'Yes'){ ?&gt;
                                &lt;?php echo "&lt;input type=\"checkbox\" name=\"Referral_mrisrs\" value=\"Yes\" checked /&gt;MRI SRS";?&gt;
                            &lt;?php }else{ ?&gt;
                                &lt;?php echo "&lt;input type=\"checkbox\" name=\"Referral_mrisrs\" value=\"No\" /&gt;MRI SRS";}?&gt;<br/>

TY again
#2

[eluser]mi6crazyheart[/eluser]
Check all these variables to get what exact info these variable content...
Code:
echo $pt['Referral_ct'];
echo $pt['Referral_mri'];
echo $pt['Referral_mrisrs'];

If these'll show "Yes" then u can say the script has some problem else u need to move backward from script to the original location to know actual value.
#3

[eluser]Todlerone[/eluser]
TY for your response. It turns out that the correct 0 or 1 was being posted to the database. I just changed it to a yes/no in the view and left the controller/model code alone.




Theme © iAndrew 2016 - Forum software by © MyBB