Categories > TinyButStrong general >

List of select box

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Violeta
Date: 2007-03-09
Time: 14:56

List of select box

Hello!
I am new with TinybutStrong. I have a problem with html plugin. I don't know how to do.

I have 3 arrays: an array "item_traseu_orar" with this fields: sterge, oraIn, oraOut and traseu (traseu is a select box!!!!!!!),
an array with the values for the selects "traseu"+i and an array that contains the values that must be selected for each "traseu"+i.
The problem is that all the fields traseu for every record is set on the first value of the select box.
Can anyoane help me? Here is the problem: <option > [var.traseu_select;ope=html;select] </option>, but I don't know how to do.

Thank you very much in advance.



$item_traseu_orar = array() ;
$item_traseu = array() ;
$traseu_select = array() ;

$item_traseu[] = array('descriere'=>'aa ','id'=>1) ;
$item_traseu[] = array('descriere'=>'bb','id'=>2) ;

$item_traseu_orar[] = array('sterge'=>'1','nr'=>'1','oraIn'=>'10:20','oraOut'=>'12:20','traseu'=>'aaaaaaaaaaaaaaa' ) ;
$item_traseu_orar[] = array('sterge'=>'','nr'=>'2','oraIn'=>'11:20','oraOut'=>'12:20','traseu'=>'bbbbbbbbbbbbbbbb' ) ;

$traseu_select = array('id'=>'2'); 
$traseu_select = array('id'=>'3');

$TBS->MergeBlock('trasee_var',$item_traseu_orar) ;
$TBS->MergeBlock('trasee',$item_traseu) ;
for ($k=0;$k<$nr_trasee_pe_pagina;$k++) {
     $TBS->MergeBlock('trasee'.$k,$item_traseu) ;
}

$TBS->MergeBlock('traseu_select',$traseu_select) ;



(this is a part of php code)


And here is the code in html:
    <tr>
      <td >
      <div align="center">
[trasee_var.sterge; if [val] == '1'; then '<input name="sterge[trasee_var.$;block=tr]" type="checkbox" id="sterge[trasee_var.$;block=tr]" value="1" checked="true" />';
else '<input name="sterge[trasee_var.$;block=tr]" type="checkbox" id="sterge[trasee_var.$;block=tr]" value="1" />';]
      </div>
      </td>
      <td ><div align="center"><input id="nr[trasee_var.$;block=tr]" name="nr[trasee_var.$;block=tr]" size="3" value="[trasee_var.nr]" type="text" readonly="true" /></div></td>
      <td ><div align="center"><input id="oraIn[trasee_var.$;block=tr]" name="oraIn[trasee_var.$;block=tr]" size="5" value="[trasee_var.oraIn]" type="text"  /></div></td>
      <td ><div align="center"><input id="oraOut[trasee_var.$;block=tr]" name="oraOut[trasee_var.$;block=tr]" size="5" value="[trasee_var.oraOut]" type="text"  /></div></td>
      <td ><div align="center">



        <select name="traseu[trasee_var.$;block=tr]" id="traseu[trasee_var.$;block=tr]" size="1" />
            <option value="0" default="true"> </option>
            <option value="[trasee[trasee_var.$;block=tr].id]">[trasee[trasee_var.$;block=tr].descriere;block=option]</option>
            <option > [var.traseu_select;ope=html;select] </option>
        </select>
       </div></td>
    </tr>

By: Skrol29
Date: 2007-03-11
Time: 01:49

Re: List of select box

Hi Violeta,

First you don"t need to repeat "block=tr" on each [trasee_var.*] fields. Only one of them is enough. The first one in the HTML code is good.

You dont need to the loop:
$TBS->MergeBlock('trasee',$item_traseu) ;
for ($k=0;$k<$nr_trasee_pe_pagina;$k++) {
  $TBS->MergeBlock('trasee'.$k,$item_traseu) ;
}

You can simply merge in first the items of the select box which are the same for all Ora records, and then merge Ora records.
Like this:
$TBS->MergeBlock('trasee',$item_traseu);
$TBS->MergeBlock('trasee_var',$item_traseu_orar);

HTML:
<select name="traseu[trasee_var.$]" id="traseu[trasee_var.$]" size="1">
  <option value="0" default="true"> </option>
  <option value="[trasee.id]">
    [trasee.descriere;block=option]
  </option>
  ... // see below for the extra selecting item
</select>


Now, in order to have all selectboxes selected with the values you've defined with $straseu_select, add the item:
  <option >
     [var.traseu_select.[trasee_var.$].id;ope=html;select]
   </option>

For example, first row will have the item:
  [var.traseu_select.0.id;ope=html;select]
This is the correct syntax to select the value of :
  $traseu_select[0]['id']
By: Violeta
Date: 2007-03-26
Time: 19:14

Re: List of select box

Thank you very very much for help and sorry for late.
There is one think that didn't work from what you said: that I don't need the loop. In html, I could't use 'trasee' for all my select box, so I am still using the loop:
for ($k=0;$k<$nr_trasee_pe_pagina;$k++) {
  $TBS->MergeBlock('trasee'.$k,$item_traseu) ;
}
But this is not a problem.
Thank you very much.
Ciao!