Changing a Radio Button to a Check Box - help please

I have this Radio button code,

<td width="16%" align="right">Bus Stop  : &nbsp;</td>
      <td width="16%" align="center">
      <input type="radio" name="vh_3R9" value="1"
      <? echo ($item_details['vh_3R9']=='1') ? "checked":""; ?>>
      <span style="COLOR: rgb(96,191,0); FONT-WEIGHT: bold">Yes</span>
      <input type="radio" name="vh_3R9" value="0"
      <? echo ($item_details['vh_3R9']=='0') ? "checked":""; ?>>
      <span style="COLOR: rgb(255,0,0); FONT-WEIGHT: bold">No</span>
    </td>

that I wanting to change to a Check Box,

<td width="16%" align="right">Bus Stop : &nbsp;</td>
    <td width="16%" align="left">
    <input type="checkbox" name="vh_3R9" value="1"
    <? echo ($item_details['vh_3R9']==1) ? 'checked' : ''; ?>/>
    </td>

yet it is not working correctly,

all help appreciated :slight_smile:

The problem is likely the processing end of the script. Instead of storing the value of $_POST[‘vh_3R9’] you’ll need to store the value of isset($_POST[‘vh_3R9’]). Technically you should use: $result = isset($_POST[‘vh_3R9’]) ? $_POST[‘vh_3R9’] : 0; Although you will get away with the former.

Hello TomB, thank you for your quick helpful reply :slight_smile:

so will each Check Box have a individual $_POST[‘vh_3R9’] needing to be changed to ($_POST[‘vh_3R9’])

or will there be one code to process all ? vh_3R9 vh_3R8 vh_3R7 vh_3R6 ?

I have not seen any code like this,

originally there was a drop menu, then I changed it to Radio Buttons.

<td width="16%" align="right">Radio/CD : &nbsp;</td>
	<td width="16%" align="center">
	<select name="vh_20" class="contentfont" id="vh_20" style="height: 20px; width: 170px">
	<option value="" selected>Select Option</option>
	<option value="1" <? echo ($item_details['vh_20']=='1') ? "selected":""; ?>>Yes</option>
	<option value="0" <? echo ($item_details['vh_20']=='0') ? "selected":""; ?>>No</option>
	</select>
	</td>

The only code I can find that has $_POST, and is connected with this is

houseland='" . $_POST['houseland'][$key] . "' WHERE category_id=" . $value);

$sql_reset_hidden = $db->query("UPDATE " . DB_PREFIX . "categories SET houseland=0 WHERE parent_id=" . $parent_id);
		$hidden_array = $db->implode_array($_POST['houseland']);
		$sql_update_hidden = $db->query("UPDATE " . DB_PREFIX . "categories SET
			houseland=1 WHERE category_id IN (" . $hidden_array . ")");

You’ll need to do the same for any radios you’re converting to checkboxes. Somewhere where it process the form it will have to check the value submitted. That’s what you need to change.

Hello, are these changes correct?

was

houseland=‘" . $_POST[‘houseland’][$key] . "’,

now

houseland=‘" . isset($_POST[‘houseland’][$key]) . "’,

was

implode_array($_POST[‘houseland’]);

now

implode_array(isset($_POST[‘houseland’]));