Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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 Smile

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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to close a Thread?
Next Topic: What's wrong with this code?
Goto Forum:
  


Current Time: Fri May 10 12:45:09 CEST 2024

Total time taken to generate the page: 0.03743 seconds