如何将jsp中<input>设为只读
2024-10-18 22:33:58
将一个input变为只读,可以使用 readonly 属性 和 disabled 属性。
用disabled 属性时,文字显示为灰色。
下面的两种方法都是可以的:
- <input id ="" name="" readonly />
- <input id ="" name="" disabled />
但是,使用 disabled 时,表单提交后,在后台将不会取到值了。
如果想得到值.就用javascript来拼值。如:
- <script>
- function onc(){
- ].mes.value;
- ].invalue=valuemes;
- ].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>
建议用 readonly
注:有时候设置某个input 是否提交,可以在js中这样写:
Java代码
- //设置可用
- document.getElementById("xxx").disabled="disabled";
- //设置不可用
- document.getElementById("xxx").enabled;
【转载自】http://lixh1986.iteye.com/blog/1746928
最新文章
- centos 7.1 apache 源码编译安装
- Sql server 2008 R2 实现远程异地备份
- hdfs创建级联文件夹
- Linux查看软件安装路径
- 第一章 OO大智慧
- SQLserver查看数据库端口 脚本
- html5 canvas 像素随机百分之十显示
- 【转】cocos2d-x游戏开发(八)各类构造器
- linux下监控进程需掌握的四个命令
- Android简单逐帧动画Frame的实现(二)
- 三、js的函数
- 关于spring事务注解实战
- 【FAQ系列】关于SQL_Errno:1677导致主从复制中断的思考和实践
- Xcode 调试技巧 --常用命令和断点
- kafka_2.11-2.1.0测试
- 2018-2019-1 20189201 《LInux内核原理与分析》第五周作业
- 20165303 魏煜第四次实验 Android开发
- 关于LVS+Nginx为什么会被同时使用的思考
- 软件-分布式:Kylin (apache开源分布式分析引擎软件)
- asynDBCenter(不断跟新)