WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Bakery Shop »
  • option values as checkbox in stead of selectbox
  • Print
Pages: [1]   Go Down

Author Topic: option values as checkbox in stead of selectbox  (Read 8527 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



Logged

Offline DarkViper

  • Forum administrator
  • *****
  • Posts: 3087
  • 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 »
Logged
Der blaue Planet - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen

"We need education to cope with digitalization - and NOT the digitalization of education.!"

Tägliches 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
Logged

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
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Bakery Shop »
  • option values as checkbox in stead of selectbox
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2