b) HTML复选框控件 当一个窗体中HTML源码包含一个复选框控件时,一般都给定唯一的名称,例如:<FORM ACTION=”show_request.asp” METHOD=”POST”>I enjoy:<INPUT TYPE=”CHECKBOX” NAME=”Reading” CHECKED> Reading <INPUT TYPE=”CHECKBOX” NAME=”Eating”> Eating <INPUT TYPE=”CHECKBOX” NAME=”Sleeping”> Sleeping<INPUT TYPE=”SUBMIT” VALUE=”Send”></FORM>
在这种情况下,提交窗体时,假如仅是第一和第三个复选框被选中(加标记),遍历Form集合时,会得到下列值:Reading = onSleeping = on
然而,假如为每个复选框提供一个值,把这个值发往服务器代替字符串“on”。例如窗体如下:<FORM ACTION=”show_request.asp” METHOD=”POST”>I enjoy:<INPUT TYPE=”CHECKBOX” VALUE=”Hobby025” NAME=”Hobby” CHECKED>_Swimming <INPUT TYPE=”CHECKBOX” VALUE=”Hobby003” NAME=”Hobby” CHECKED>_Reading <INPUT TYPE=”CHECKBOX” VALUE=”Hobby068” NAME=”Hobby”>Eating <INPUT TYPE=”CHECKBOX” VALUE=”Hobby010” NAME=”Hobby”>Sleeping<INPUT TYPE=”SUBMIT” VALUE=”Send”></FORM>