- <html:radio property="consumptionClass" value="花了" >花了</html:radio>
- <html:radio property="consumptionClass" value="賺了" >賺了</html:radio>
- <html:radio property="consumptionClass" value="借出" >借出</html:radio>
- <html:radio property="consumptionClass" value="借入" >借入</html:radio>
<html:radio property="consumptionClass" value="花了" >花了</html:radio><html:radio property="consumptionClass" value="賺了" >賺了</html:radio><html:radio property="consumptionClass" value="借出" >借出</html:radio><html:radio property="consumptionClass" value="借入" >借入</html:radio>
方法1
在jsp頁面最后面加入
-
- <script>
-
- alert("${consumptionClass}");
-
- if("${consumptionClass}" == "花了")
- {
- document.all("consumptionClass")[0].checked=true;
- }
- if("${consumptionClass}" == "賺了")
- {
- document.all("consumptionClass")[1].checked=true;
- }
- if("${consumptionClass}" == "借出")
- {
- document.all("consumptionClass")[2].checked=true;
- }
- if("${consumptionClass}" == "借入")
- {
- document.all("consumptionClass")[3].checked=true;
- }
- </script>
-
-
<script>alert("${consumptionClass}");if("${consumptionClass}" == "花了"){document.all("consumptionClass")[0].checked=true;//第一個radio選中}if("${consumptionClass}" == "賺了"){document.all("consumptionClass")[1].checked=true;//第二個radio選中}if("${consumptionClass}" == "借出"){document.all("consumptionClass")[2].checked=true;//第三個radio選中}if("${consumptionClass}" == "借入"){document.all("consumptionClass")[3].checked=true;//第四個radio選中}</script>
方法2
要讓<html:
radio>選擇很關(guān)鍵的一點,就是,這個JSP勢必對應(yīng)的一個actionform吧,給它個初始值就OK了
默認(rèn)值是動態(tài)的話
請注意到name屬性
性別
- <html:radio value="花了" property="consumptionClass" name="cco">花了</html:radio>
- <html:radio value="賺了" property="consumptionClass" name="cco">賺了</html:radio>
- <html:radio value="借出" property="consumptionClass" name="cco">借出</html:radio>
- <html:radio value="借入" property="consumptionClass" name="cco">借入</html:radio>