<form method="post" name="input" action="#">
<td bgcolor="#F8F8F8" width="20%">知识适用人员:</td>
<td bgcolor="#FFFFFF">
<select name="knowledgeperson" onChange=changelocation(document.input.knowledgeperson.options[document.input.knowledgeperson.selectedIndex].values);document.cookie="id="+this.selectedIndex+";cid=0">
  <option value="" selected>>>>>请选择<<<<</option>
  <OPTION values='1' >测试人员</OPTION>
  <OPTION values='2' >开发人员</OPTION>
  <OPTION values='3' >客服人员</OPTION>
<SCRIPT language=JavaScript>
var onecount;
onecount=0;
subcat = new Array();
subcat[0] = new Array(1,'可行性分析阶段');
subcat[1] = new Array(2,'需求分析阶段');
subcat[2] = new Array(3,'概要设计阶段');
subcat[3] = new Array(1,'11111');
subcat[4] = new Array(2,'22222');
subcat[5] = new Array(3,'33333');
subcat[6] = new Array(1,'44444');
subcat[7] = new Array(2,'55555');
subcat[8] = new Array(3,'66666');
onecount=9;<?php
?>
function changelocation(locationid)
{
document.input.knowledgeuse.length = 0;
var locationid=locationid;
var i,flag=0;
for (i=0;i < onecount; i++)
{
if (subcat[i][0] == locationid)
{
document.input.knowledgeuse.options[document.input.knowledgeuse.length] = new Option(subcat[i][1]);
flag=1;
}
}
if (flag==0)
{
document.input.knowledgeuse.options[document.input.knowledgeuse.length] = new Option('>>>>请先选择知识适用人员<<<<');
}
}</SCRIPT>
</select>
</td>
</tr>
<tr>
<td bgcolor="#F8F8F8" width="20%">知识适用阶段:</td>
<td bgcolor="#FFFFFF"> 
<select name="knowledgeuse" onchange=document.cookie="cid="+this.selectedIndex>
  <option value="" selected>>>>>请先选择知识适用人员<<<<</option>
  </select></td>
  <input type="button" value="重来" onclick="chonglai()">
</form>
<script>
if (document.cookie)
{
var tmp = document.cookie.split(";");
var id = tmp[0].split("=");
var cid = tmp[1].split("=");

document.input.knowledgeperson.selectedIndex = id[1];
changelocation(document.input.knowledgeperson.options[document.input.knowledgeperson.selectedIndex].values);
document.input.knowledgeuse.selectedIndex = cid[1];
}
function chonglai()
{
document.cookie = "id=0;cid=0";
}
</script>

解决方案 »

  1.   

    修改:
    1.第一个列表
    <select name="knowledgeperson" onChange=changelocation(document.input.knowledgeperson.options[document.input.knowledgeperson.selectedIndex].values);document.cookie="id="+this.selectedIndex+";cid=0">2.第二个列表
    <select name="knowledgeuse" onchange=document.cookie="cid="+this.selectedIndex>
      <option value="" selected>>>>>请先选择知识适用人员<<<<</option>
      </select></td>
      <input type="button" value="重来" onclick="chonglai()">3.文件最后添加
    <script>
    if (document.cookie)
    {
    var tmp = document.cookie.split(";");
    var id = tmp[0].split("=");
    var cid = tmp[1].split("=");

    document.input.knowledgeperson.selectedIndex = id[1];
    changelocation(document.input.knowledgeperson.options[document.input.knowledgeperson.selectedIndex].values);
    document.input.knowledgeuse.selectedIndex = cid[1];
    }
    function chonglai()
    {
    document.cookie = "id=0;cid=0";
    }
    </script>
      

  2.   

    没有用PHP,用IE打开,选择以后,再刷新,会显示原有有选择,点重来,去掉选择。