Try with :
#if("$entry.id" == "$selection")
(explicit string comparison)
Note that $entry.getId() and $entry.getValue() can be written $entry.id
and $entry.value
Claude
-- CODE --
> #macro( selectionbox $class $name $selection $list )
> <select class="$class" name="$name" size="1">
> #foreach( $entry in $list )
> #if( $entry.getId() == $selection )
> <option value="$entry.getId()" selected>$entry.getValue()</option>
> #else
> <option value="$entry.getId()">$entry.getValue()</option>
> #end
> #end
> </select>
> #end
> -- CODE --
>
Le dimanche 18 février 2007 à 13:10 +0100, Mark Wassermann a écrit :
> hi list
>
> I have a problem with a macro that should build a ht ml select element.
>
> The macro is as follows:
>
> -- CODE --
> #macro( selectionbox $class $name $selection $list )
> <select class="$class" name="$name" size="1">
> #foreach( $entry in $list )
> #if( $entry.getId() == $selection )
> <option value="$entry.getId()" selected>$entry.getValue()</option>
> #else
> <option value="$entry.getId()">$entry.getValue()</option>
> #end
> #end
> </select>
> #end
> -- CODE --
>
> $list is a list of torque objects
> $selection is an int value representing the current selected item of the
> list
>
> The problem is, that the line
> #if( $entry.getId() == $value )
> never returns true and there is no selected item in the selectionbox
> (the box always shows the first element)
>
> I do not understand the reason for this behavior.
> What did I miss?
>
> thx for help
> Mark
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]