Welcome Guest, Not a member yet? Register   Sign In
set_radio problem
#3

[eluser]TheFuzzy0ne[/eluser]
Something that just occured to me... This may also work, and may make your code a bit more readable.

Code:
$attrs = array('name' => 'result', 'id' => 'id_resultval_1', 'class' => 'inputRadio');
    echo form_radio($attrs, '1', set_radio('result', '1'));

Lets assume you have the value of the checkbox stored in your database as an integer (0=unchecked, 1=checked), and the column was called my_checkbox. You can pull the data out of the database, generate an array of default values based on that. You could then do the following to set the default value:
Code:
$attrs = array('name' => 'result', 'id' => 'id_resultval_1', 'class' => 'inputRadio');
    echo form_radio($attrs, '1', set_radio('result', '1', ($defaults['my_checkbox'] == '1'));


Messages In This Thread
set_radio problem - by El Forum - 03-11-2013, 07:13 AM
set_radio problem - by El Forum - 03-11-2013, 08:13 AM
set_radio problem - by El Forum - 03-11-2013, 08:31 AM
set_radio problem - by El Forum - 03-12-2013, 01:45 AM
set_radio problem - by El Forum - 03-12-2013, 11:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB