Categories > TinyButStrong general >

select option html tag

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: handoko
Date: 2010-06-27
Time: 02:28

select option html tag

Dear Skrol, and team,

i have a problem when using field into option select html tag with selected parameter.

What i want is when the page first load, it should display the option select number by default, i have made my code like the below but it doesn't work.

this is the code;
index.php
<?
include_once('tbs_class_php5.php');

$catlist[0] = array('catid'=>"3", 'catname'=>"baju hamil");
$catlist[1] = array('catid'=>"2", 'catname'=>"baju hamil lengan panjang");
$catlist[3] = array('catid'=>"5", 'catname'=>"baju hamil lengan pendek");

$main = new clsTinyButStrong;
$main->LoadTemplate('option.html');
$main->MergeBlock('cat',$catlist);

$main->show();   
?>

while the option.html contain code:
<form name="form1" method="post" action="" onsubmit="return cekmandatory()">
<TABLE cellpadding="0" cellspacing="0" class="Tbl0" width="100%">
        <tr>
          <td class="B01">Kategori</td>
          <td class="BS">:</td>
          <td>
            <select name="catid">    
<option value="[cat.catid;block=option;noerr]" [cat.catid;if [val]="2";then ' selected';else '';noerr] >[cat.catname;noerr] </option>               
            </select>           
          </td>
        </tr>
       
        </TABLE>
</form>

hope you can find the solution. thanks
By: Skrol29
Date: 2010-06-27
Time: 22:17

Re: select option html tag

Hi Handoko,

The HTML plug-in which is provided with the TBS package does perform select for form elements. There are also examples on line.

Otherwise, I can see 2 problems with your code. It should be working when fixed. First you should not write "2" but '2', because double quote is not s string delimiter for TBS. And after, you should code (selected="selected") instead of (selected).
<option value="[cat.catid;block=option;noerr]" [cat.catid;if [val]=2;then 'selected="selected"';else '';noerr] >[cat.catname;noerr] </option>
By: handoko
Date: 2010-07-02
Time: 15:54

Re: select option html tag

Hi skrol,

Thanks for the reply,

how  ever i found that the cause is come from the array itself,
the array item doesnot have the same content, for example
array b[1] = {catid=>"1", catname=>"satu", catparent=>NULL}
array b[2] = {catid=>"1", catname=>"satu"}

this is the source of the problem why my code previous doen't consistent in doing a assesment.