英文:
With out changing the order of "select:Option" how to make a specific option as selected by default in visual force <apex:seleList>?
问题
<apex:page>
<apex:form>
<apex:selectList size="1">
<apex:selectOption itemLabel="猿" itemValue="猿"/>
<apex:selectOption itemLabel="蝙蝠" itemValue="蝙蝠"/>
<apex:selectOption itemLabel="猫" itemValue="猫"/>
<apex:selectOption itemLabel="狗" itemValue="狗"/>
<apex:selectOption itemLabel="大象" itemValue="大象"/>
</apex:selectList>
</apex:form>
</apex:page>
在不改变<apex:selectOption>的顺序的情况下,要使"狗"成为默认选择,您可以使用以下代码。
英文:
<apex:page >
<apex:form>
<apex:selectList size="1">
<apex:selectOption itemLabel="Ape" itemValue="Ape"/>
<apex:selectOption itemLabel="Bat" itemValue="Bat"/>
<apex:selectOption itemLabel="Cat" itemValue="Cat"/>
<apex:selectOption itemLabel="Dog" itemValue="Dog"/>
<apex:selectOption itemLabel="Elephant" itemValue="Elephant"/>
</apex:selectList>
</apex:form>
</apex:page>
Here "Ape" is selected by default since it is the first option but With out changing the order of the <apex:selectOption> I want to make "Dog" as selected by default.
Please tell me how to achieve this without using Apex and without using script if possible
Thanks in advance
答案1
得分: 1
Without Apex and JavaScript? that's a lot of limitation and I don't know what's the point of the page, how are you going to use the value in any way.
You could always downgrade it all the way to pure HTML
<apex:page>
<select>
<option>Ape</option>
<option>Bat</option>
<option>Cat</option>
<option selected="true">Dog</option>
<option>Elephant</option>
</select>
</apex:page>
英文:
Without Apex and JavaScript? that's a lot of limitation and I don't know what's the point of the page, how are you going to use the value in any way.
You could always downgrade it all the way to pure HTML
<apex:page>
<select>
<option>Ape</option>
<option>Bat</option>
<option>Cat</option>
<option selected="true">Dog</option>
<option>Elephant</option>
</select>
</apex:page>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论