js根据下拉框选择的值显示输入框

页面显示

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="Page_Table_Common">
	<tr>
		<td class="Page_TableLabel_Center" width="80">
			是否外籍:
		</td>
		<td class="Page_TableText_Left" width="90" >
			<select onchange="selectSfwj();" id="sfwj">
				<option value="0">否</option>
				<option value="1">是</option>
			</select>
		</td>
		<td class="Page_TableLabel_Center" width="40">
			姓名:
		</td>
		<td class="Page_TableText_Left" width="150">
			<ww:textfield id="rcxm" name="rcxm" cssClass="txtBox"
						  theme="simple"></ww:textfield>
		</td>
		<td class="Page_TableLabel_Center" width="70">
			证件号码:
		</td>
		<td class="Page_TableText_Left" width="200">
			<ww:textfield id="rczjhm" name="rczjhm" cssClass="txtBox"
						  theme="simple"></ww:textfield>
		</td>
		<td class="Page_TableLabel_Center" width="80" id="rcz_xm" style="display: none">
			人才证姓名:
		</td>
		<td class="Page_TableText_Left" width="150" id="rczxm_input" style="display: none">
			<ww:textfield id="rczxm" name="rczxm" cssClass="txtBox"
						  theme="simple"></ww:textfield>
		</td>
		<td class="Page_TableLabel_Center" width="100" id="rcz_zjhm" style="display: none">
			人才证证件号码:
		</td>
		<td class="Page_TableText_Left" width="200" id="rczzjhm_input" style="display: none">
			<ww:textfield id="rczzjhm" name="rczzjhm" cssClass="txtBox"
						  theme="simple"></ww:textfield>
		</td>
	</tr>
</table>

IE中页面写法
(项目中用到easyUI)

<script type="text/javascript">
    function selectSfwj(){
        window.console && console.log($("#sfwj").val());
        if ( document.getElementById('sfwj').value == 1){
            document.getElementById("rcz_xm").style.display="block";
            document.getElementById("rczxm_input").style.display="block";
            document.getElementById("rcz_zjhm").style.display="block";
            document.getElementById("rczzjhm_input").style.display="block";
            $("#ts_td").attr("colSpan",11); //注意大小写
        }else {
            document.getElementById("rcz_xm").style.display="none";
            document.getElementById("rczxm_input").style.display="none";
            document.getElementById("rcz_zjhm").style.display="none";
            document.getElementById("rczzjhm_input").style.display="none";
            $("#ts_td").attr("colSpan",7); //注意大小写
        }
    }
</script>
上一篇:网络安全专家呼吁特朗普*建立民用网络DARPA


下一篇:前端周刊第六期