當前位置:編程學習大全網 - 源碼下載 - 怎樣制作jsp級聯選項框

怎樣制作jsp級聯選項框

<html>

<head>

<title>SIGN UP</title>

<%

Class.forName("org.gjt.mm.mysql.Driver").newInstance();

String url ="jdbc:mysql://localhost/reg?user=root&password=625&useUnicode=true&characterEncoding=ISO8859_1" ;

Connection conn= DriverManager.getConnection(url);

Statement stmt=conn.createStatement();

ResultSet rs;

%>

<script language = "JavaScript">

var onecount;

onecount=0;

subcat = new Array();

<%

int count = 0;

rs=stmt.executeQuery("select * from University");

while(rs.next())

{

String university=new String(rs.getString("University").getBytes("GBK"),"ISO8859_1");

%>

subcat[<%=count%>] = new Array("<%="university"%>","<%=rs.getInt("InCountry")%>","<%=rs.getInt("PI_Key")%>");//2úéúêy×é

<%

count = count + 1;

}

%>

onecount=<%=count%>;

function changelocation(id)

{

document.form1.uselect.length = 0;

var id=id;

var i;

document.form1.uselect.options[0] = new Option('--Select--','');

for (i=0;i < onecount; i++)

{

if (subcat[i][1] == id)

{

document.form1.uselect.options[document.form1.uselect.length] = new Option(subcat[i][0], subcat[i][2]);

}

}

}

</script>

<script LANGUAGE=javascript>

changelocation(document.form1.ctselect.options [document.form1.ctselect.selectedIndex].value); //將壹級分類的value傳給changelocation()函數,生成二級分類的列表

</script>

</head>

<body>

<div align="center"></div>

<form name="form1" method="post" action="" >

<table width="609" border="1" align="center">

<tr>

<td width=21% height="2" bgcolor="#efefef"> <div align="center" class="style2">Surname</div></td>

<td width=79% height="2"><span class="style2"><b>

<b>

<input name="Surname" type="text" id="date" size="60">

</b> </b></span></td>

</tr>

<tr>

<td width=21% height="2" bgcolor="#efefef"> <div align="center" class="style2">GivenName</div></td>

<td width=79% height="2"><span class="style2"><b>

<b>

<input name="GivenName" type="text" id="date" size="60">

</b> </b></span></td>

</tr>

<tr>

<td width=21% height="2" align="center" bgcolor="#efefef">Country</td>

<td height="2"><span class="style5">

<select name="ctselect" id="ctselect" onChange="changelocation(document.form1.ctselect.options[document.form1.ctselect.selectedIndex].value)">

<option value="2">--Select--</option>

<%

rs=stmt.executeQuery("select * from Country");

while(rs.next())

{

String Country = new String(rs.getString("Country").getBytes("ISO8859_1"),"ISO8859_1");

System.out.println(Country);

%>

<option value="<%=rs.getInt("PI_Key")%>"><%=Country%></option>

<%

}

%>

</select></td>

</tr>

<tr>

<td width=21% height="2" align="center" bgcolor="#efefef">University</td>

<td>

<select name="uselect">

<option value="" selected>--Select--</option>

</select>

</td>

</tr>

<tr>

<td width=21% height="15" bgcolor="#efefef"> <div align="center" class="style8">City</div></td>

<td height="15">

<span class="style8">

<input name="City" type="text" id="date" size="60">

</font></b></span></td>

</tr>

<tr>

<td height="15" bgcolor="#efefef"> <div align="center">Organization</div></td>

<td height="15"> <input name="Organization" type="text" id="date" size="60">

</td>

</tr>

<tr>

<td height="15" bgcolor="#efefef"> <div align="center">Street</div></td>

<td >

<input name="Street" type="text" id="date" size="60">

</td>

</tr>

<tr>

<td width=21% height="15" bgcolor="#efefef"> <div align="center">Phone</div></td>

<td ><input name="Phone" type="text" id="date" size="60">

</td>

</tr>

<tr>

<td width=21% height="15" bgcolor="#efefef"> <div align="center">PostalCode</div></td>

<td height="15"><input name="PostalCode" type="text" id="date" size="60">

<div align="center"></div></td>

</tr>

<tr>

<td height="44" colspan="2">

<div align="center">

<input type="submit" name="Submit3" value="1">

?

<input type="reset" name="Submit22" value="2">

</div></td>

</tr>

</table>

</form>

</center>

</div>

</body>

</html>

  • 上一篇:蕪湖海螺國際會議中心的室內設計
  • 下一篇:深圳久遊。com源代碼
  • copyright 2024編程學習大全網