function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
d3developerd3developer 

Writing conditionals in HTML with Visualforce

I've been experiencing some strange behavior.

 

This code in a Visualforce page:

 

 

	          <option value="{!v.so.value}" {!IF(v.selected == TRUE,'selected="selected"','')}>{!v.so.label}, {!IF(v.selected == TRUE,'selected','not selected')}</option>

 

 

Results in this HTML:

 

 

           <option selected="selected" value="Option 5" >Option 5, not selected</option>

 

Note two very bizarre things:

 

(1) The order of the elements in the option (selected and value) is reversed.

 

 

(2) It always renders the if true condition even when the condition is false (this happens only inside the element tag, not for HTML).

 

 

Ideas as to why either of these is happening?

 

 

oski1993oski1993

Re: 1 - I've seen other XML-based UI markup tools that do something similar with XML element attributes... I imagine that technically the order of the "option" attributes shouldn't matter because it's still valid, parse-able XML, so maybe the ordering of the attributes is not considered important by the VF HTML renderer also...