<%-- Document : a Created on : 2008-6-16, 11:59:30 Author : 王界涵--%><%@ page contentType="text/html" pageEncoding="UTF-8"%><!--使用哪些包--><%@ page import="java.util.List"%><%@ page import="cma.model.cf.Cfdictarea"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><!--後台綁定的JAVABEAN--><jsp:useBean id="testJspBean" scope="page" class="cma.cf.testJspVBean"/><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> <link type="text/css" rel="stylesheet" href="../../css/StyleSheet.css" /> </head> <body> <form id = "from1" name = "from1" method="post"> <table border="1"> <tr> <td> <select name=""> <!--當所有option都有selected時,不可用selected="",否則失效--> <option value = "1">1</option> <option selected="selected" value ="2">2</option> <option value ="3" >3</option> <option value ="4" >4</option> </select></td> <td> <select name = "select1"> <!--<option selected>==所有地區==</option>--> <% List list = testJspBean.getBatchidgroups();//擷取地區列表 for (int i = 0; i < list.size(); i++) { Cfdictarea cf = new Cfdictarea(); cf = (Cfdictarea) list.get(i);//將LIST的每項對象化 %> <!--綁定下拉選並用SELECTED屬性判斷哪個被選中--> <option value="<%=cf.getAreacode()%>" <%=cf.getAreacode().toString().equals("ATJ") ? "selected" : ""%>><%=cf.getAreaname()%></option> <%}%> </select> </td> </tr> <tr> <td> <% //測試文字框綁定 String k = "ATJ"; %> <input type="text" value="<%=k.equals("ATJ") ? "selected" : ""%>"/> </td> <td> </td> </tr> </table> <!--綁定地區列表--> <table border="1"> <thead> <tr> <th>地區代碼</th> <th>地區名稱</th> </tr> </thead> <tbody> <% List viewList = testJspBean.getBatchidgroups(); for (int i = 0; i < viewList.size(); i++) { Cfdictarea cfa = new Cfdictarea(); cfa = (Cfdictarea) viewList.get(i); %> <tr> <td><%=cfa.getAreacode()%></td> <td><%=cfa.getAreaname()%></td> </tr> <%}%> </tbody> </table> </form> </body></html>