![]() |
form_vaidation: dynamic Default-value for radio, select, checkbox? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: form_vaidation: dynamic Default-value for radio, select, checkbox? (/showthread.php?tid=19592) |
form_vaidation: dynamic Default-value for radio, select, checkbox? - El Forum - 06-12-2009 [eluser]Unknown[/eluser] Hello, is there a way to dynamically set the default-Value for radio-buttons? According to the documentation you can set the default-Value for a radio-button like this: Code: <input type="radio" name="myradio" value="1" <?php echo set_radio('myradio', '1', TRUE); ?> /> In my case I read a value from a database and want to activate the according value (1 or 2) in the radio-button. Is there something like Code: <input type="radio" name="myradio" value="1" <?php echo set_radio('myradio', '1', $default_1); ?> /> form_vaidation: dynamic Default-value for radio, select, checkbox? - El Forum - 06-12-2009 [eluser]darkhouse[/eluser] Try this: Code: <input type="radio" name="myradio" value="1" <?php echo set_radio('myradio', '1', ($value_from_db == 1)); ?> /> |