WML教程10:分组选择控件(Optgroup)和复杂实例
相关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>