<html>
<head>
<title>样品信息登陆</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript" type="text/JavaScript">
<!--
function selected(a){
  switch (a)
  {
  case "0001":document.all.Layer1.style.display ="none";break;
  case "0002":document.forms.text1.value="折光";break;
  default:""
  }
}
!-->
</script></head><body bgcolor="#ECF2FD">
<form action="" method="post" name="forms">
  <p>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0" class=box onload="selected()">
  <tr> 
    <td height="25" bgcolor="#BDCFF0" class="title"> 填写条码与标签</td>
  </tr>
  <tr> 
    <td height="1" bgcolor="#6080d1"></td>
  </tr>
  <tr> 
    <td align="center" valign="top"> <br> 
      <table width="95%" border="0" cellspacing="0" cellpadding="0" class="s2">
        <tr> 
          <td width="12%" height="30" align="center">项目编号</td>
            <td width="33%" height="30">  
              <select name="numbers" class="box" onChange="selected(options[this.selectedIndex].text)">
                <option value="0">——</option>
                <option value="0001" >0001</option>
                <option value="0002">0002</option>
              </select></td>
          <td width="11%" height="25" align="center">样品编号</td>
          <td width="44%" height="25">   
            <input name="text1" type="text" class="box" size="20" readonly="true" ></td>
        </tr>
      </table>
      <br> </td>
  </tr>
</table>
</form>
<br>
<form method="post" name="form2" >
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="61">
     <div id="Layer1" style="position:relative; left:0px; top:0px; width:600px; height:117px; z-index:1; visibility: hidden; background-color: #0066FF; layer-background-color: #0066FF; border: 1px none #000000;"> 
        </div>
        <div id="Layer2" style="position:relative; left:0px; top:0px; width:600px; height:117px; z-index:1; visibility: hidden; background-color: #CC6600; layer-background-color: #CC6600; border: 1px none #000000;"> 
        </div></td>
  </tr>
</table></form>
</body>
</html>

解决方案 »

  1.   

    div不是表单元素,只是一个标签而已,用document.form2.Layer1.style.display是不能正常显示的
      

  2.   

    谢谢,可是我用document.form2.Layer1.style.display="??"除了none还有什么!
    这个方法我也试了,还是不可以!
      

  3.   

    document.form2.Layer1
    这个不是对象
    div不是一个表单的标签,所以前面不用加form2
      

  4.   

    Layer2:
    document.getElementById('Layer2').style.display="none";//block;document.form2.text2.value="折光"function selected(a){
      switch (a)
      {
      case "0001":
    {
    document.getElementById('Layer1').style.display ="none";
    document.forms.text1.value=""
    break;
    }
      case "0002":
    {
    document.getElementById('Layer1').style.display ="block";
    document.forms.text1.value="折光";
    break;
    }
      }
    }