<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>sss</title>
</head>
<form name="form1">
  <table border="0" align="center" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" height="30">
    <tr>
      <td height="24">
   <select name="type" onclick='if(this.options[this.selectedIndex].text=="3"){document.all("dwmc").style.display="";document.all("xm").style.display=""}else{document.all("dwmc").style.display="none";document.all("xm").style.display="none"}'>
     <option value="1">按身份证号查询 </option>
     <option value="2">按个人帐号查询 </option>
              <option value="3">按姓名加单位名称查询 </option>
   </select>
         <input type="text" name="text1" size="12">
<td id="dwmc" style="display:none">
         单位名称:<input type="text" name="text1" size="12">
         </td>
         <td id="xm" style="display:none">
         姓名:<input type="text" name="text2" size="12">
      </td>
    </tr>
  </table>
  </form>
</body>
</html>

解决方案 »

  1.   

    <select name="type" onClick="if(this.options[this.selectedIndex].value=="3"){this.dwmc.display="block;this.xm.display="block"}else{this.dwmc.display="none;this.xm.display="none"}">最好写到一个函数里
      

  2.   

    楼上的大哥,我把你给我的写到<select>里,为什么没有反应呢?
      

  3.   

    不要用this.dwmc而应该用document.all("dwmc")
    另外if(a==b)中要用"=="来判断而不是"=","="是赋值按我下面的写法可以通过,我测试过了,你试试!onclick='if(this.options[this.selectedIndex].value=="3"){document.all("dwmc").style.display="";document.all("xm").style.display=""}else{document.all("dwmc").style.display="none";document.all("xm").style.display="none"}'