+ Start a Discussion
rotfilrotfil 

Dropdown selected error - Element type "option" must be followed by either attribute specifications, ">" or "/>

<apex:repeat var="fruit" value="{!fruit}" id="fruit">

	<select class="form-control" id="fruit">

		<option value="Apple" {!IF(fruit.fruit__c=='apple','selected','')}>Apple</option>

	</select>

</apex:repeat>
All I want to do is put the following like of code

{!IF(fruit.fruit__c=='apple','selected','')} into a select option but oh no:

Element type "option" must be followed by either attribute specifications, ">" or "/>

Rubbish - how can I create a work around for this?
 
Best Answer chosen by rotfil
Dilip_VDilip_V
Hi,

I think you missed "selected" 
Try this code once 
<apex:repeat var="fruit" value="{!fruit}" id="fruit">

	<select class="form-control" id="fruit">

		<option value="Apple"  slected="{!IF(fruit.fruit__c=='apple','selected','')}">Apple</option>

	</select>

</apex:repeat>

Let me know if it works.

Thanks.

All Answers

Dilip_VDilip_V
Hi,

I think you missed "selected" 
Try this code once 
<apex:repeat var="fruit" value="{!fruit}" id="fruit">

	<select class="form-control" id="fruit">

		<option value="Apple"  slected="{!IF(fruit.fruit__c=='apple','selected','')}">Apple</option>

	</select>

</apex:repeat>

Let me know if it works.

Thanks.
This was selected as the best answer
rotfilrotfil
Dam - it worked! Thanks for that, saved me hours of bs.. Cheers
rotfilrotfil
Actually it didn't work - although it managed to save the code. The correct HTML is simply selected. So here, the last value in the option list is always selected. I used jQuery instead.