Categories > TinyButStrong general >

Having trouble populating select and option tags

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: John
Date: 2011-04-22
Time: 16:40

Having trouble populating select and option tags

I'm trying to populate two select tags, which each have a few option tags, using TBS. I've done this before but the logic I've used before is not quite working for me.

Here's a snippet of my template code:

<p class="attributes">
    <label for="[product_attributes_1.attribute_name][product_attributes;block=p;serial]">[product_attributes_1.attribute_name;block=p]:</label>
    <select name="attr_[product_attributes.attribute_name;block=p]" id="attr_[product_attributes.attribute_name;block=p]">
        <option value="">Select one</option>
        <option value="[product_attributes_1.attribute_value_id;block=option]">[product_attributes_1.attribute_value;block=option]</option>                       
    </select>
</p>
</td>

What I usually do to populate my label, select and option html tags is I include the code block=XXX at the end of my bracketed TBS tags.  The problem I'm having is when I type block=p, I'm getting multiple <p></p> tags on my page each of which have a singe <option></option> tags rather than one <p></p> with multiple <option></option> tags.

When I try block=td, I get multiple td tags each with a single <option></option> tag.

When I try block=tr, I get multiple tr tags each with single <option></option> tags.

What is going on here?
By: Skrol29
Date: 2011-04-22
Time: 22:30

Re: Having trouble populating select and option tags

Hi John,

Can you explain what you need to have after the merging?

I can see two strange things in your snippet:
- you're using the "serial" mode whil you have only one secondary block (product_attributes_1)
- you're repeating "block=p" or "block=option" on several fields, while only one is needed per section of block.
By: John
Date: 2011-04-22
Time: 22:53

Re: Having trouble populating select and option tags

Regarding serial mode, I'm probably going to create product_attributes_2 block soon. I created product_attributes_1 because there are already some serial blocks on this page and I was unsure if the lack of a designated serial block in this section was what was causing my problem. 

After my merge I'd like two select tags, one named "Color" and another named "Size." I thought the following code is how I'd accomplish this.
<select name="attr_[product_attributes.attribute_name;block=p]" id="attr_[product_attributes.attribute_name;block=p]">

I'd like the select tag for Color to have a list of colors as options. I thought the following code would do that.
<option value="">Select one</option>
<option value="[product_attributes.attribute_value_id;block=option]">[product_attributes.attribute_value]</option>
By: Skrol29
Date: 2011-04-24
Time: 00:17

Re: Having trouble populating select and option tags

but how are structured your data?
With which data do you feed the "color" list and the "size" list?