Categories > TinyButStrong general >

List SELECT

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Maz
Date: 2005-08-04
Time: 03:48

List SELECT

I have the following code:

                    <tr>
                        <td class="dark">
                            Skins Displayed Per Page:
                        </td>
                        <td class="light">
                            [onload_skinlist;block=td;when [var.mbr_config.subscriber]=1]
                            <select class="textbox" name="skincount" id="skincount">
                                <option value="[skinlist.id]">[skinlist.name;block=option]</option>
                            </select>
                        </td>
                        <td class="light">
                            [onload_skinlist;block=td;when [var.mbr_config.subscriber]=0]
                            [lang.subscribe_feature]
                        </td>
                    </tr>

which is compiled from:

    $skin_items      = array();
    $skin_items[]    = array('name'  =>'3',   'id'=>"3");
    $skin_items[]    = array('name'  =>'6',   'id'=>"6");
    $skin_items[]    = array('name'  =>'10',   'id'=>"10");
    $skin_items[]    = array('name'  =>'15',   'id'=>"15");

    $TBS->MergeBlock('skinlist',$skin_items);

which works fine. However, I'm stuck. The selected value for the list, will be determined by a value in the database 3, 6, 10, or 15, dpending on the user's individual settings. I need that value to be shown as selected in the list when they next visit their settings page.

How can I show it as selected as I don't know which one should be selected at render time?

Thanks for any help provided.
By: Maz
Date: 2005-08-04
Time: 09:32

Re: List SELECT

Cancel above, I figured it from the examples. <Makes note to read examples more before asking.>

For anyone else who has the same issue:, the solution was to grab the number to be selected first, which I already had in a variable:

$skinnum_select = $mbr_config['skin_per_page'];

and then append the selected code to the foot of the list:

                            <select class="listbox" name="skincount" id="skincount">
                                <option value="[skinlist.id]">[skinlist.name;block=option]</option>
                                <option>[var.skinnum_select;selected]</option>
                            </select>

Damn, I love the flexibility of TBS!