Home  >  Article  >  Backend Development  >  option下拉菜单,该怎么处理

option下拉菜单,该怎么处理

WBOY
WBOYOriginal
2016-06-13 12:27:00894browse

option下拉菜单
假设有两个select option的下拉菜单:

选择下拉菜单中的值通过按钮保存:


怎么能让option为1的时候按钮隐藏 为2的时候才可以点击.在线急等......
附js:

function checkSubmit()<br />{<br />	clearError();<br />    var data = new Array();<br />    var name1 = $('#name').val();<br />    isNotBlank(name1, '名称', data);<br />    if (data.length > 0) {<br />        showWarning(data);<br />        return true;<br />    }<br />    $('#frmdirection').submit();<br />}



------解决思路----------------------
<br /><select name="country" id="city"><br /><option value="1"> -请选择- </option><br /><option value="2">test</option><br /></select><br /><input name="save" type="button"  class="" value="保存" onclick="javascript:checkSubmit();" style="display:none"/><br /><br /><SCRIPT LANGUAGE="JavaScript" src="jquery.min.js"></SCRIPT><br /><SCRIPT LANGUAGE="JavaScript"><br />$('#city').change(function(){<br />	var val=$(this).val();<br />	if(val==2){<br />		$("input[name=save]").show();<br />	}else{<br />		$("input[name=save]").hide();<br />	}<br />})<br /></SCRIPT><br />

------解决思路----------------------
$('[name="save"]').hide();<br />$('#city').change(function() {<br />  if($(this).val() != 1) $('[name="save"]').show();<br />)}<br />

------解决思路----------------------
js 版
<br /><select name="country" id="city" onChange="change(this);"><br /><option value="1"> -请选择- </option><br /><option value="2">test</option><br /></select><br /><input id="save" name="save" type="button"  class="" value="保存" onclick="javascript:checkSubmit();" style="display:none"/><br /><br /><SCRIPT LANGUAGE="JavaScript"><br />function change(_this){<br />	var val=_this.options[_this.selectedIndex].value;<br />	if(val==2){<br />		document.getElementById('save').style.display="inline";<br />	}else{<br />		document.getElementById('save').style.display="none";<br />	}<br />}<br /></SCRIPT><br />

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn