已经做好的代码,下拉的控制
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%><%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<form action="form" method="post">
<table>
<tr>
<td>
<select id="sel" onChange="chg()" >
<option value="1" >1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</td>
</tr>
<tr>
<td><input type="text" id ="apid" name="apid" value="1"/></td><td><input type="text" id ="apid" name="apid" value="2"/></td><td><input type="text" id ="apid" name="apid" value="3"/></td>
</tr>
</table>
</form>
</body>
<script type="text/javascript">
var mycars = new Array()
alert (mycars.length);
mycars[0] = "Saab"
mycars[1] = "Volvo"
mycars[2] = "BMW"
if(mycars.length == 3) {
alert (mycars.length);
var sel=document.getElementById('sel');
var option=sel.options[sel.selectedIndex = 0];
document.getElementsByName("apid")[0].value="46";
}
if(document.getElementById("sel").value=="1"){
document.getElementsByName("apid")[1].style.display="none";
document.getElementsByName("apid")[2].style.display="none";
} else if (document.getElementById("sel").value=="2") {
document.getElementsByName("apid")[2].style.display="none";
}
function chg(){
if(document.getElementById("sel").value=="1"){
document.getElementsByName("apid")[0].style.display="";
document.getElementsByName("apid")[1].style.display="none";
document.getElementsByName("apid")[2].style.display="none";
}
if(document.getElementById("sel").value=="2"){
document.getElementsByName("apid")[0].style.display="";
document.getElementsByName("apid")[1].style.display="";
document.getElementsByName("apid")[2].style.display="none";
}
if(document.getElementById("sel").value=="3"){
document.getElementsByName("apid")[0].style.display="";
document.getElementsByName("apid")[1].style.display="";
document.getElementsByName("apid")[2].style.display="";
}
}
</script>
</html>
--------------------编程问答-------------------- --------------------编程问答--------------------
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<form action="form" method="post">
<table>
<tr>
<td>
<select id="sel" onChange="chg()" >
<option value="1" >1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</td>
</tr>
<tr>
<td><input type="text" id ="apid" name="apid" value="1"/></td><td><input type="text" id ="apid" name="apid" value="2"/></td><td><input type="text" id ="apid" name="apid" value="3"/></td>
</tr>
</table>
</form>
</body>
<script type="text/javascript">
var mycars = new Array()
alert (mycars.length);
mycars[0] = "Saab"
mycars[1] = "Volvo"
mycars[2] = "BMW"
if(mycars.length == 3) {
alert (mycars.length);
var sel=document.getElementById('sel');
var option=sel.options[sel.selectedIndex = 0];
document.getElementsByName("apid")[0].value="46";
}
if(document.getElementById("sel").value=="1"){
document.getElementsByName("apid")[1].style.display="none";
document.getElementsByName("apid")[2].style.display="none";
} else if (document.getElementById("sel").value=="2") {
document.getElementsByName("apid")[2].style.display="none";
}
function chg(){
if(document.getElementById("sel").value=="1"){
document.getElementsByName("apid")[0].style.display="";
document.getElementsByName("apid")[1].style.display="none";
document.getElementsByName("apid")[2].style.display="none";
}
if(document.getElementById("sel").value=="2"){
document.getElementsByName("apid")[0].style.display="";
document.getElementsByName("apid")[1].style.display="";
document.getElementsByName("apid")[2].style.display="none";
}
if(document.getElementById("sel").value=="3"){
document.getElementsByName("apid")[0].style.display="";
document.getElementsByName("apid")[1].style.display="";
document.getElementsByName("apid")[2].style.display="";
}
}
</script>
</html>
补充:Java , J2ME