takeiteasy Posted May 8, 2006 Share Posted May 8, 2006 In my Add form, i have radio buttons for payment mode consisting of Cash, Credit Card and Cheque. If i select the radio button for Cash, MySQL will add the record as 'Cash' right....but wad if i wan to display the stored record in my Edit form in radio button Cash, Credit Card. Cheque, checked Cash? how do i go about the code?TIA!This is my code in Add form[code]<input type='radio' name='paymentMode' value='Cash'>Cash <input type='radio' name ='paymentMode' value='CreditCard'>Credit Card <input type='radio' name ='paymentMode' value='Cheque'>[/code] Quote Link to comment Share on other sites More sharing options...
trq Posted May 8, 2006 Share Posted May 8, 2006 If $row['payment'] holds said value, something like....[code]<input type='radio'<?php ($row['payment'] == 'Cash') ? echo 'checked="checked" : echo ''; ?> name='paymentMode' value='Cash'>Cash<input type='radio'<?php ($row['payment'] == 'Credit') ? echo 'checked="checked" : echo ''; ?> name ='paymentMode' value='CreditCard'>Credit Card<input type='radio'<?php ($row['payment'] == 'Cheque') ? echo 'checked="checked" : echo ''; ?> name ='paymentMode' value='Cheque'>[/code]should do it. Quote Link to comment Share on other sites More sharing options...
takeiteasy Posted May 8, 2006 Author Share Posted May 8, 2006 i've tried your solution but it still can't work. The radio buttons are still not checked. Any other soultions? Thanks! Quote Link to comment Share on other sites More sharing options...
takeiteasy Posted May 9, 2006 Author Share Posted May 9, 2006 I have tried this but still not working...can someone help?[code]<?php $ca = $nets = $cc = ''; ?> <?php if ($paymentMode == 'Cash') { $ca = ' checked'; } else if ($paymentMode == 'Nets') { $nets = 'checked'; } else { $cc = 'checked'; } } ?> <input type='radio' name='paymentMode' value='Cash' echo $ca;>Cash <input type='radio' name ='paymentMode' value='Nets' echo $nets;>Nets <input type='radio' name ='paymentMode' value='Cheque' echo $cc;>Cheque [/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.