将一个input变为只读,可以使用 readonly 属性 和 disabled 属性。 

用disabled 属性时,文字显示为灰色。 

下面的两种方法都是可以的:

  1. <input id ="" name=""  readonly   />
  2. <input id ="" name=""  disabled />

但是,使用 disabled 时,表单提交后,在后台将不会取到值了。 



如果想得到值.就用javascript来拼值。如:

  1. <script>
  2. function onc(){
  3. ].mes.value;
  4. ].invalue=valuemes;
  5. ].submit();
  6. }
  7. </script>
  8. <form action="test">
  9. <input type="hidden" name="invalue">
  10. <input type="text" value="你好" name="mes" disabled="disabled">
  11. <input type="button" value="提交" onclick="onc()">
  12. </form>

建议用 readonly 





注:有时候设置某个input 是否提交,可以在js中这样写:

Java代码  
  1. //设置可用
  2. document.getElementById("xxx").disabled="disabled";
  3. //设置不可用
  4. document.getElementById("xxx").enabled;
【转载自】http://lixh1986.iteye.com/blog/1746928

最新文章

  1. centos 7.1 apache 源码编译安装
  2. Sql server 2008 R2 实现远程异地备份
  3. hdfs创建级联文件夹
  4. Linux查看软件安装路径
  5. 第一章 OO大智慧
  6. SQLserver查看数据库端口 脚本
  7. html5 canvas 像素随机百分之十显示
  8. 【转】cocos2d-x游戏开发(八)各类构造器
  9. linux下监控进程需掌握的四个命令
  10. Android简单逐帧动画Frame的实现(二)
  11. 三、js的函数
  12. 关于spring事务注解实战
  13. 【FAQ系列】关于SQL_Errno:1677导致主从复制中断的思考和实践
  14. Xcode 调试技巧 --常用命令和断点
  15. kafka_2.11-2.1.0测试
  16. 2018-2019-1 20189201 《LInux内核原理与分析》第五周作业
  17. 20165303 魏煜第四次实验 Android开发
  18. 关于LVS+Nginx为什么会被同时使用的思考
  19. 软件-分布式:Kylin (apache开源分布式分析引擎软件)
  20. asynDBCenter(不断跟新)

热门文章

  1. win8.1开启虚拟wifi
  2. C语言知识总结(3)
  3. bootstrap-fileinput初体验
  4. cpoint
  5. 使用记事本+CSC编译程序
  6. 《搭建DNS内外网的解析服务》RHEL6
  7. LR通过SiteScope监控mysql
  8. js正则学习及一些正则集合
  9. [转]浅析AD Exchange——RTB模式
  10. rhel_7.x 安装mysql