Forum Moderators: phranque

Message Too Old, No Replies

Convert "radio" to "checkbox"

         

Garibaldi3489

9:31 pm on Sep 13, 2006 (gmt 0)

10+ Year Member



I have some radio boxes on my site that users can select. However, these radio buttons only let users select one option, I would like for them to be able to click more than one option, which you can do with a checkbox. How can I convert a script on my phpBB to do this?

physics

1:37 am on Sep 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This might be a custom job since the PHP code to submit one selected entry will be different for code that submits more than one selected entry. You might want to search the phpbb forums for your specific issue or look into hiring a programmer. Either that or post more specific info here because right now it seems too general.

Garibaldi3489

3:27 am on Sep 14, 2006 (gmt 0)

10+ Year Member



I'll post some excerpts from the MOD for phpBB, maybe that will help.

1:

switch ($info['field_type'])
{
case 'text':
$template->assign_block_vars('xdata.switch_type_text', array());
break;

case 'textarea':
$template->assign_block_vars('xdata.switch_type_textarea', array());
break;

case 'radio':
$template->assign_block_vars('xdata.switch_type_radio', array());

while ( list( , $option) = each($info['values_array']) )
{
$template->assign_block_vars('xdata.switch_type_radio.options', array(
'OPTION' => $option,
'CHECKED' => ($xdata[$code_name] == $option)? 'checked="checked"' : ''
)
);
}
break;

case 'select':
$template->assign_block_vars('xdata.switch_type_select', array());

while ( list( , $option) = each($info['values_array']) )
{
$template->assign_block_vars('xdata.switch_type_select.options', array(
'OPTION' => $option,
'SELECTED' => ($xdata[$code_name] == $option)? 'selected="selected"' : ''
)
);
}
break;
}
}
elseif ($info['display_register'] == XD_DISPLAY_ROOT)
{
$template->assign_block_vars('xdata',
array(
'CODE_NAME' => $code_name,
'NAME' => $xd_meta[$code_name]['field_name'],
'DESCRIPTION' => $xd_meta[$code_name]['field_desc'],
'VALUE' => isset($xdata[$code_name])? str_replace('"', '"', $xdata[$code_name]) : ''
) );
$template->assign_block_vars('xdata.switch_is_'.$code_name, array());

switch ($info['field_type'])
{
case 'radio':

while ( list( , $option) = each($info['values_array']) )
{
$template->assign_block_vars('xdata.switch_is_'.$code_name.'.options', array(
'OPTION' => $option,
'CHECKED' => ($xdata[$code_name] == $option)? 'checked="checked"' : ''
)
);
}
break;

case 'select':

while ( list( , $option) = each($info['values_array']) )
{
$template->assign_block_vars('xdata.switch_is_'.$code_name.'.options', array(
'OPTION' => $option,
'SELECTED' => ($xdata[$code_name] == $option)? 'selected="selected"' : ''
)
);
}
break;

2:

<!-- BEGIN switch_type_radio -->
<tr>
<td class="row1">
<span class="gen">{xdata.NAME}</span><br /><span class="gensmall">{xdata.DESCRIPTION}</span>
</td>
<td class="row2">
<!-- BEGIN options -->
<input type="radio" name="{xdata.CODE_NAME}" value="{xdata.switch_type_radio.options.OPTION}" {xdata.switch_type_radio.options.CHECKED} />
<span class="gen">{xdata.switch_type_radio.options.OPTION}</span><br />
<!-- END options -->
</td>
</tr>
<!-- END switch_type_radio -->

Thanks

physics

5:21 am on Sep 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Wild guess: try doing a global replace of radio to checkbox.

Garibaldi3489

1:33 am on Sep 15, 2006 (gmt 0)

10+ Year Member



I tried that, and it didn't work. After doing that the new section on the profile didn't even show up. I also tried select replacements and that also didn't work

vincevincevince

2:23 am on Sep 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Odds are that the value chosen is stored in a database. Odds are that there is only support for one value in that record. Bets on you needing a PHP programmer to rework the script and the database?

Garibaldi3489

2:43 am on Sep 15, 2006 (gmt 0)

10+ Year Member



Ok, in that case I guess I'll just have to deal with one. Its too bad though. Thanks a lot for your insight!