I added some radio buttons to a PHP form in osCommerce. I plan on adding a bunch more but in the meantime I have four right now. I'm wondering if I need to set all the radio buttons as true/false or just the single instance I want as true.
Here's the code I have:
if (!isset($pInfo->tab_id)) $pInfo->tab_id = '1';
switch ($pInfo->tab_id) {
case '0': $none_tab_id = true; $shirt_tab_id = false;
$coverall_tab_id = false; $glove_tab_id = false;
break;
case '1': $coverall_tab_id = true; $shirt_tab_id = false;
$none_tab_id = false; $glove_tab_id = false;
break;
case '2': $coverall_tab_id = false; $shirt_tab_id = true;
$none_tab_id = false; $glove_tab_id = false;
break;
case '3': $glove_tab_id = true; $coverall_tab_id = false;
$shirt_tab_id = false; $none_tab_id = false;
break;
default: $coverall_tab_id = false; $shirt_tab_id = true;
$none_tab_id = false;
}
.
<?php
echo ' None' . tep_draw_radio_field('tab_id', '0', $none_tab_id) .
' coveralls' . tep_draw_radio_field('tab_id', '1', $coverall_tab_id) .
' Shirts' .tep_draw_radio_field('tab_id', '2', $shirt_tab_id) .
' Gloves' . tep_draw_radio_field('tab_id', '3', $glove_tab_id);
?>
osCommerce defines the tep_draw_radio_field
function as this:
tep_draw_radio_field($name, $value = '', $checked = false, $compare = '')
Is it necessary to set all the variables to false
in each case or if can I just set the one I want to true?