Categories > TinyButStrong general >

"tbs_plugin_html.php" & "select" on multiple checkboxes

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: ryan
Date: 2007-02-15
Time: 15:28

"tbs_plugin_html.php" & "select" on multiple checkboxes

I have a list of checkboxes, I am trying to select the ones that are already "on" so to sayy.

here is my php
$TBS->MergeBlock('prods',$cnx_id,"SELECT * FROM products");
$TBS->MergeBlock('cats',$cnx_id,"SELECT * FROM categories");
$TBS->MergeBlock('opts',$cnx_id,"SELECT * FROM options");
$p = mysql_fetch_array(mysql_query("SELECT * FROM products ORDER BY prodId DESC"));
$v = mysql_fetch_array(mysql_query("SELECT * FROM variations ORDER BY varId DESC"));
$newProdId = $p['prodId'] + 1;
$defaultVarId = $v['varId'] + 1;
if($subpg=='edit'){
    $TBS->MergeBlock('prod',$cnx_id,"SELECT * FROM products JOIN categories ON prodCatId = catId WHERE prodId = '".$_GET['id']."'");
    $TBS->MergeBlock('pos',$cnx_id,"SELECT * FROM prod_opts WHERE prodId = '".$_GET['id']."'");
    $TBS->MergeBlock('varis',$cnx_id,"SELECT * FROM variations WHERE varProdId = '".$_GET['id']."'");
}
}

and my template...

<label>Options</label>
<ol class="options">
    <li>[opts; block=li]<label><input type="[opts.optType]" name="options[]" value="[opts.optId]" /> [opts.optName]</label>[pos.optId; ope=html; select = [pos.optId]]</li>
</ol>

I hope that makes sense... basically i have a table in my database that links "products" to "options" called "prod_opts" and when I list all the options for a specific product, I want the options linked to that product to be checked...

Thanks, I hope this is possible, but if not, I will find a work around...
By: sheepy
Date: 2007-02-16
Time: 10:09

Re: "tbs_plugin_html.php" & "select" on multiple checkboxes

The html standard plugin maybe able to help:
http://tinybutstrong.com/plugins.php?help#plugin_html

(But then, maybe not... reply if you need further help)
By: ryan
Date: 2007-02-16
Time: 13:34

Re: "tbs_plugin_html.php" & "select" on multiple checkboxes

Yeah, i am not sure the standard help for the plugin was so helpful, lol i used it for select boxes fine, but i cant seen to get multiple selections to work...
By: sheepy
Date: 2007-02-22
Time: 13:25

Re: "tbs_plugin_html.php" & "select" on multiple checkboxes

OK, it looks like you only show one set of options in the page which simplifies things.  However I still can't get it to work, and it seems to be a bug.

Here is what I've got, I removed lots of irrelevant stuffs and simplified things a lot.

PHP:
$TBS->MergeBlock('opts', array(1,2,3,4,5)); // options
$TBS->MergeBlock('pos', array(1,2)); // options to check
$TBS->Show()

HTML:
<ol>
  <li>
    <input type="checkbox" name="options[]" value="[opts.val; block=li]" /> [opts.val]
  </li>
<!--[pos.val; block=_]--> [pos.val; ope=html; select='options[]'; selbounds=ol]
</ol>

I had hoped to combine [pos] block into [pos] html field, but even in this form the html field does not merge.  I tried wrapping the line with some tag but they still don't merge.

It's not relevant, but I discovered that tbs falls into infinite loop if I try to merge single html select field when selbounds is not set and there are no <form> to be found.