将一个input变为只读,可以使用 readonly 属性 和 disabled 属性。
用disabled 属性时,文字显示为灰色。
下面的两种方法都是可以的:
[color=red]但是,使用 disabled 时,表单提交后,在后台将不会取到值了。[/color]
如果想得到值.就用javascript来拼值。如:
[b][color=red]建议用 readonly[/color] [/b]
[b]注:[/b]有时候设置某个input 是否提交,可以在js中这样写:
引用:
[url]http://bbs.youkuaiyun.com/topics/380063466[/url]
-
转载请注明
原文出处: http://lixh1986.iteye.com/blog/1746928
-
-
用disabled 属性时,文字显示为灰色。
下面的两种方法都是可以的:
<input id ="" name="" readonly />
<input id ="" name="" disabled />
[color=red]但是,使用 disabled 时,表单提交后,在后台将不会取到值了。[/color]
如果想得到值.就用javascript来拼值。如:
<script>
function onc(){
var valuemes=document.form[0].mes.value;
document.form[0].invalue=valuemes;
documnet.form[0].submit();
}
</script>
<form action="test">
<input type="hidden" name="invalue">
<input type="text" value="你好" name="mes" disabled="disabled">
<input type="button" value="提交" onclick="onc()">
</form>
[b][color=red]建议用 readonly[/color] [/b]
[b]注:[/b]有时候设置某个input 是否提交,可以在js中这样写:
//设置可用
document.getElementById("xxx").disabled="disabled";
//设置不可用
document.getElementById("xxx").enabled;
引用:
[url]http://bbs.youkuaiyun.com/topics/380063466[/url]
-
转载请注明
原文出处: http://lixh1986.iteye.com/blog/1746928
-
-