Author Topic: option values as checkbox in stead of selectbox  (Read 5778 times)

Offline Bug

  • Posts: 237
option values as checkbox in stead of selectbox
« on: May 12, 2011, 09:53:27 AM »
is there a way to change the selectbox for the option values into a checkboxlist

something like

Code: [Select]
// Show form to add new item attributes
echo "<tr height='50' class='mod_showroom_submit_row_b'>\n<td>\n";
// Get options and attributes
$query_options = $database->query("SELECT o.option_name, o.option_id, a.attribute_id, a.attribute_name FROM ".TABLE_PREFIX."mod_showroom_options o INNER JOIN ".TABLE_PREFIX."mod_showroom_attributes a ON o.option_id = a.option_id ORDER BY o.option_name, a.attribute_name ASC");
if ($query_options->numRows() > 0) {
// Generate option and attribute select

while($option = $query_options->fetchRow()) {
$option = array_map('stripslashes', $option);
// Only display if not listed in the item attributes table above
if (in_array($option['attribute_id'], $listed_attribute_ids))
continue;
echo "<input type='checkbox' value='{$option['attribute_id']}'";
echo $attribute_id == $option['attribute_id'] ? " selected='selected'" : "";
echo "/>{$option['option_name']}: {$option['attribute_name']}<br />";
}

} else {
echo "{$TEXT['NONE_FOUND']}&nbsp;&nbsp;<a href='".WB_URL."/modules/showroom/modify_options.php?page_id=$page_id&amp;section_id=$section_id'>&gt; {$TEXT['ADD']}/<span style='text-transform: lowercase;'>{$TEXT['MODIFY']}/{$TEXT['DELETE']}</span></a>";
}
?>
  </td>
  <td align="left"><?php echo $fetch_settings[&#39;shop_currency&#39;]; ?>
<select name="ia_operator">
  <option value="+"<?php echo $ia_operator == "+" " selected=&#39;selected&#39;" ""?>> + </option>
  <option value="-"<?php echo $ia_operator == "-" " selected=&#39;selected&#39;" ""?>> - </option>
  <option value="="<?php echo $ia_operator == "=" " selected=&#39;selected&#39;" ""?>> = </option>
</select>
<input type="text" name="ia_price" style="width: 60px; text-align: right;" maxlength="150" value="<?php echo $ia_price?>" />
<input type="hidden" name="db_action" value="<?php echo $db_action?>" />
  </td>
  <td>&nbsp;</td>
  <td colspan="2"><input type="submit" name="save_attribute" value=" <?php echo $TEXT[&#39;ADD&#39;]; ?> " />
  </td>
</tr>
</table>
</form>

where i replaced the selectbox for

Code: [Select]
echo "<input type='checkbox' value='{$option['attribute_id']}'";
echo $attribute_id == $option['attribute_id'] ? " selected='selected'" : "";
echo "/>{$option['option_name']}: {$option['attribute_name']}<br />";

the problems:

- it does not save
- i do not know hoe to display the pricebox for each separate value




Offline DarkViper

  • Forum administrator
  • *****
  • Posts: 3049
  • Gender: Female
Re: option values as checkbox in stead of selectbox
« Reply #1 on: May 12, 2011, 10:34:43 PM »
a group of radio-buttons or checkboxes works like a dropdownbox

Code: [Select]
<?php

  </
td>
  <td align="left"><?php echo $fetch_settings[&#39;shop_currency&#39;]; ?>

<input type="checkbox" name="ia_operator" value="+"<?php echo $ia_operator == "+" " selected=&#39;selected&#39;" ""?> /> +
<input type="checkbox" name="ia_operator" value="-"<?php echo $ia_operator == "-" " selected=&#39;selected&#39;" ""?> /> -
<input type="checkbox" name="ia_operator" value="="<?php echo $ia_operator == "=" " selected=&#39;selected&#39;" ""?> /> =
<input type="text" name="ia_price" style="width: 60px; text-align: right;" maxlength="150" value="<?php echo $ia_price?>" />

?>

but if one option only should be selectable, it's better to use radio-buttons
« Last Edit: May 12, 2011, 10:38:20 PM by DarkViper »
Der blaue Planet - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen

"You have to take the men as they are… but you can not leave them like that !" :-P
Das tägliche Stoßgebet: Oh Herr, wirf Hirn vom Himmel !

Offline Bug

  • Posts: 237
Re: option values as checkbox in stead of selectbox
« Reply #2 on: May 12, 2011, 10:42:10 PM »
I guess you are talking about frontend....

I am talking about the backend...

So no, it is never that only one option should be selected with optionvalues, otherwise one wou
D not have to use optionvalues...

This item is only available in red,

That does not need optionvalue


That item is available in green blue and pink,

One cannot select those colors to be added to the optionfields

Offline Bug

  • Posts: 237
Re: option values as checkbox in stead of selectbox
« Reply #3 on: November 07, 2011, 07:23:24 PM »
Can someone take a look at this?

Maybe freesbee himself?

I would really like it if i can choose all needed option. Alues at once in stead of selecting the options one by one

If anyone still does not get it, I am talking about the backend, where you put the item info in

I am building a t shirtshop with quite some option fields (4 categories, each 4 to 8 options) and for 150 shirt designs...

I just want selectboxes in stead of a dropdown optionselector