Home » U++ Library support » U++ MT-multithreading and servers » Witz and map variable
Re: Witz and map variable [message #38052 is a reply to message #38050] |
Thu, 29 November 2012 11:11 |
|
Zbych wrote on Thu, 29 November 2012 10:37 | I have one more question for you.
I have a drop list and want to preselect one value from it.
Right now I create a map ("Item1", "0")("Item2", "1")("Item3", "0"), pass it to witz and use $if to preselect position.
<select name="MyList">
$for(i in MYLIST)
$if ( i != 0 )
<option value="$i._key" selected="selected">$i._key</option>
$else
<option value="$i._key">$i._key</option>
$/
$/
</select>
| I'm not aware of any other simple way, I do it like this too. Only alternative I know about is sending MYLIST as an array of arrays/maps of two field, where the second contains the "selected=\"selected\"" or empty string, so it can be included in single pass, without $if. But it seems to me even worse, because it pushes html code into app
Zbych wrote on Thu, 29 November 2012 10:37 | Is there a shorter way (without $if)? Maybe something similar to c?
$for(i in MYLIST)
<option value="$i._key" $(i != 0) ? selected="selected" : "">$i._key</option>
$/
| I believe (can't test right now) you can inline the $if:$for(i in MYLIST)
<option value="$i._key" $if(i != 0) selected="selected" $/>$i._key</option>
$/
Honza
|
|
|
Goto Forum:
Current Time: Fri May 10 12:45:09 CEST 2024
Total time taken to generate the page: 0.03743 seconds
|