BLOGJAVA

index.jsp

<%@page contentType="text/html;charset=GBK" %>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<script language="javascript" src="js/prototype-1.6.0.2.js"></script>
<script language="javascript">
function doTest(key){
 var url = "data.jsp";
 var params = "key=" + key;
 new Ajax.Request(url,{
  method: 'get',
  parameters: params,
  onComplete: showResponse
 });
}

function showResponse(req){
 var temp = req.responseText;
 var arrStr = temp.split("|");
 $("s2").options.length = 0;
 
 for(var i=0;i<arrStr.length;i++){
  var arrV = arrStr[i].split(","); 
  $("s2").options[i+1] = new Option(arrV[1],arrV[0]);
 }
}
</script>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
  <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="120">
        <select name="s1" id="s1" style="width:100" onchange="doTest(this.value)">
          <option value="1">A类</option>
          <option value="2">B类</option>
        </select>
      </td>
      <td width="120">
        <select name="s2" id="s2" style="width:100">
          <option value="1">A1</option>
          <option value="2">A2</option>
        </select>
      </td>
      <td>
        <input type="button" name="Button" value=" 测试 ">
      </td>
    </tr>
  </table>
</form>
</body>
</html>

posted on 2008-05-13 09:08 七页 阅读(140) 评论(0)  编辑  收藏 所属分类: 2级联动无刷新


只有注册用户登录后才能发表评论。


网站导航: