Issue
i need to create an HTML drop down menu with option variable based on external list.
i'm tryng with:
set item_list [$var]
<select>
<option value="$item_list">$item_list</option>
<option value="$item_list">$item_list</option>
<option value="$item_list">$item_list</option>
<option value="$item_list">$item_list</option>
<option value="$item_list">$item_list</option>
</select>
but what i obtain is all option in this way
{volvo saab opel audi}
Any suggest?
Solution
Manually creating the HTML code is one option:
set item_list {volvo saab opel audi}
set html_code "<select>"
foreach item $item_list {
append html_code "<option value=\"$item\">$item</option>"
}
append html_code "</select>"
puts $html_code
However, there are other template processing packages described here. Since you didn't describe your use case in greater detail, this should suffice.
Answered By - Alecu Ștefan-Iulian
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.