问问select控件的失效问题 disabled是不能传值的,是不是其他地方设了默认值 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select控件的值是从数据库中读出的,当读出test2的值时,控件应当变灰,不让选择,同时提交该页面的时候,select不能传值,而系统默认为0,提交了该控件的0值,所以也更改了我数据库中的值,变为0,当在此显示该页面时,变成了test1,大家有什么好的办法,从页面上解决这个问题,在控件变灰的状态下,让它提交1值,也可以。我试过在onsubmit函数中 document.form1.test.value = 1;但是结果同上 先设一个变量var t,在每次onChange下拉框的时候现将value值赋给t,这样提交的时候提交t的值就可以了,楼主44 楼主还是注意一下书写吧, disabled onchange 都写漏了<script>function Mdvalue(){ if(document.form1.test.options[document.form1.test.selectedIndex].value == 1){ document.form1.test.disabled = true; }}</script><form name="form1"><select name="test" onchange="Mdvalue()"><option value="0">test1</option><option value="1">test2</option><option value="2">test3</option></select></form> document.form1.test.selectedIndex是获取当前选中的第几个选项,用document.form1.test.options[document.form1.test.selectedIndex].value来拿值 wee_zhou(苦啤酒) 谢谢批评指教,我是图简单楼上几位都是在select控件激活的状态下完成的,我的问题是select控件的值是从数据库中读出的,当值为1时显示test2,控件应当变灰不可用,不让用户选择,当提交该页面的时候,失效的select不能传值,但是此时系统默认selelct控件值为0,提交了该控件的0值,所以也更改了我数据库中的值,变为0,应当是不能改变的。当再显示该页面时,却变成了test1。我想当select变灰显示test2时,虽然select控件失效,也提交1值,我试过在onsubmit函数中 document.form1.test.value = 1;但是结果同上,还是提交的值0,大家都什么好的办法? 没有完全看懂你的意思. 你试试把你需要的select控件值放到hidden里边处理,看看对你有无用?(<input type="hidden" >) 求三角公示 spring security 获取Authentication对象为null 关于javasscipt作用域的问题,求解 下面两种定义对象的方式有何区别? 请问如何实现列的可见性 2.1+2.1+2.1 = 6.300000000000001 为什么?如何解决? 鼠标点击行,变色问题!!!!!!!!!!!请了!! 能在浏览器上输出曲线吗?? 鼠标事件冲突!!!在线等候!!!! 关于dc.js的问题!求用过的帮助! title属性的问题 showModalDialog打开的对话框如何可以向另一个网页传值并控制该页面让该值显示出来
document.form1.test.value = 1;
但是结果同上
function Mdvalue(){
if(document.form1.test.options[document.form1.test.selectedIndex].value == 1){
document.form1.test.disabled = true;
}
}
</script><form name="form1">
<select name="test" onchange="Mdvalue()">
<option value="0">test1</option>
<option value="1">test2</option>
<option value="2">test3</option>
</select>
</form>
document.form1.test.value = 1;
但是结果同上,还是提交的值0,大家都什么好的办法?
你试试把你需要的select控件值放到hidden里边处理,看看对你有无用?(<input type="hidden" >)