select 和 input 的不可编辑,input隐藏

select 没有readOnly属性

在jsp中

<select  id="a" name="a" disabled="disabled">             disabled确实能使该选择框不能编辑 但是同时也将使其中的值不能提交

  <option>A</option>

  <option>B</option>

  <option>C</option>

</select>

如果你正好用的是google,而且又想提交表单,建议再定义一个<input>存放select的数值,隐藏起来(hidden="true")。那么提交就提交成功该数值了(name要和select的一样的哦~)

<span onmousemove="this.setCapture();" onmouseout="this.releaseCapture();" onfocus="this.blur();">

  <select  id="a" name="a">                                   span中的意思是当获焦时 失焦,这样就不能选了,但是google不支持

    <option>A</option>                                      并且jeecg中的<t:dictSelect>也能这样不可选

    <option>B</option>

    <option>C</option>

  </select>

</span>

在js中

$("#a").attr('disabled',true);

input

在jsp中

<input id="b" name="b" disabled="disabled"/>                    disabled确实能使该文本框不能编辑 但是同时也将使其中的值不能提交

<input id="b" name="b" readOnly="readOnly"/>                  readOnly能使该文本框不能编辑 而且可以提交其中的值,但是ie8不支持

在js中

$("#b").attr('disabled',true);

$("#a").attr('readOnly',true);

如果你的客户又要用ie8又要用google,我也不知道怎么办了。知道的同学麻烦告诉我一下哦~灰常感谢- -

input隐藏

type="hidden"  

hindden="hidden"  ie8中还是能看见

原文地址:https://www.cnblogs.com/xlj227/p/6039175.html