用javascript实现某个隐藏域控制多个控件的一个问题?
有没有高手用javascript实现这样一个问题,当某个隐藏域(<input type="hidden" name="loader" value="ADMIN"> )的(value)值不等于某个字符串时,多个select,多个text,多个button变为不可用,呈灰色,能否举个例子,把源码传上来?<input type="hidden" id="s" value="1" onpropertychange="changeValue()"> <input type="button" onclick="add(this)" value="隐藏字段值:1"> <br> <br> <select name="e1" id="e1"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> </select> <select name="e2" id="e2"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> </select> <input type="text" name="e3" id="e3" value=1> <input type="text" name="e4" id="e4" value=2> <input type="text" name="e5" id="e5" value=3> <input type="button" name="e6" id="e6" value=1> <input type="button" name="e7" id="e7" value=2> <input type="button" name="e8" id="e8" value=3> <script language="JavaScript"> <!-- var $=document.getElementById; function add(obj) { $("s").value = parseInt($("s").value)+1; obj.value="隐藏字段值:" + $("s").value; } function changeValue() { var _value=parseInt(s.value); if (_value % 2 == 0) disableAll(); else releaseAll(); } function disableAll() { for(var i=1 ;i<9;i++) $("e" + i).disabled=true; } function releaseAll() { for(var i=1 ;i<9;i++) $("e" + i).disabled=false; } //--> </script>
<input type="hidden" id="s" value="1" onpropertychange="changeValue()"> <input type="button" onclick="add(this)" value="隐藏字段值:1"> <br> <br> <div id=dis> <select> <option>1</option> <option>2</option> <option>3</option> <option>4</option> </select> <select> <option>1</option> <option>2</option> <option>3</option> <option>4</option> </select> <input type="text" value=1> <input type="text" value=2> <input type="text" value=3> <input type="button" value=1> <input type="button" value=2> <input type="button" value=3> </div> <script language="JavaScript"> <!-- var $=document.getElementById; function add(obj) { $("s").value = parseInt($("s").value)+1; obj.value="隐藏字段值:" + $("s").value; } function changeValue() { var _value=parseInt(s.value); if (_value % 2 == 0) $("dis").disabled=true; else $("dis").disabled=false; } //--> </script>