相關Option分組產生層級,對最終用戶來說可能沒有什麼意義,但是對於制作者來說,Option分組可以提供很多方便。
相關屬性:
1. title 標題,通常這種標題無法被顯示
示例:
<card>
<p> What OS You Use Now?
<select name="OS">
<optgroup title="microsoft">
<option value="dos">DOS</option>
<option value="windows">Windows</option>
</optgroup>
<optgroup title="others">
<option value="unix">unix</option>
<option value="Linux">Linux</option>
</optgroup>
</select>
</p>
</card>
上例演示了一個基本的Optgroup元素的應用,由於Optgroup沒有變量參數,所以只能提供有限的應用。
一個比較復雜的例子:
<?XML version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.XML">
<wml>
<template>
<do type="options" label="Back">
<prev/>
</do>
</template>
<card id="lists">
<p>
<select title="Pick Lists">
<option onpick="#JY">Jin Yong</option>
<option onpick="#GL">Gu Long</option>
</select>
</p>
</card>
<card id="JY">
<onevent type="onenterbackward">
<prev/>
</onevent>
<do type="accept">
<go href="#display_fav"/>
</do>
<p> Pick your fav Book:
<select name="fav" title="Stooges">
<option value="Xiao">Xiao ao jiang hu</option>
<option value="She">She diao ying xiong</option>
<option value="Lu">Lu ding ji</option>
<option value="Shen">Shen diao xia lv</option>
</select>
</p>
</card>
<card id="GL">
<onevent type="onenterbackward">
<prev/>
</onevent>
<do type="accept">
<go href="#display_fav"/>
</do>
<p> Pick your fav Book.
<select multiple="true" title="Gu Long" name="fav" >
<option value="Gu">Gu xing zhuan</option>
<option value="Da">Da di fei ying</option>
<option value="Tian">Tian ya ming yue dao</option>
<option value="feng">Lu xiao feng</option>
</select>
</p>
</card>
<card id="display_fav">
<p> Your fav was $fav. </p>
</card>
</wml>