form表单内容

来源:互联网 发布:并行计算的编程模型 编辑:程序博客网 时间:2024/06/05 16:59
  1. form表单中包含的:
     action=“要提交的页面;method=“提交的方式”
     enctype=“multipart/form-data”:结合type=“file”如果不加这个图片传入后台就会知识图片的名字,如果加的话传入后台的就是图片的信息;
  1. <textarea></textarea> 输入框
     属性:cols=“可见的列数”  rows=“可见的行数”;       
  1. detalist 与input一起;组成下拉提示框;
<input type="text" list="main">
<datalist id="main">
    <option>fdaf</option>
    <option>fdaf</option>
</datalist>
detalist一般和搜索一起使用;
  1. select  其中有optgroup可以分组;
  2. input的type类型:
         <!--button按钮--><input type="button"> 
          只是普通的按钮;不能提交;  但是<button>按钮</button>能提交;
<!--文本输入框--><input type="text">
<!--密码输入框--><input type="password">
<!--文件选择按钮--><input type="file">在form中添加enctype=“multipart/form-data”属性,传到后台的值是图片的详细值;如不添加词属性,传到后台的就是图片的名字;
<!--范围选择--><input type="range" min=""  max="" value="" step=""> 
<!--颜色选择--><input type="color">
<!--邮件输入框--><input type="email">
<!--url地址输入框--><input type="url">
<!--提交按钮--><input type="submit">
<!--重置按钮--><input type="reset">
<!--搜索按钮--><input type="search">
<!--数字输入框--><input type="number" min=""  max="" step="点击跳跃的步数">
<!--日期选择框--><input type="date">
<!--时间日期选择框--><input type="datetime">
<!--本地时间日期选择框--><input type="datetime-local">
<!--月输入框--> <input type="mouth">
<!--星期输入框--><input type="week">
<!--隐藏输入框--><input type="hidden"> 隐藏的,但是后台可以读取到值;
<!--图片按钮--><input type="image"> 
<!--单选框--><input type="radio">
<!--多选框--><input type="checkbox" name="sec[]">
                     <input type="checkbox" name="sec[]">
radio和checkbox 要有name值和value值才能传到后台;但是checkbox的name值后边必须加[ ]否则只能那个传递一个值,不能将选择的都传递给后台;

以上文本框中,都必须有name的值,才能往后台传值,但是传的都是value的值;
  1. input的属性: required--必填项;  readonly--只读;placeholder--默认显示的文字; value--默认显示的文字;disabled--不可用的; autofocus--获得焦点;
          size:可看见的字符; maxlength--输入的最多字符;
          checked:默认选中;单选框、多选框;选中;
          selected:下拉菜单选中状态;
          readonly与disabled的都是不可以更改,但是readonly可以往后台传值,disabled不可以往后台传值;
  1. 选中文字,即可选中文本框:让label中的for和input中的id相等即可;
          <label for="nini">姓名<input type="radio" id="nini"> </label>
  1. 注意事项:
     title改变提示语言只能跟pattern正则使用;别的改变不了提示语言;
     placeholder与value的区别:两个同时存在:placeholder会被覆盖;value的值会被传递给后台;placeholder的值不会被传递给后台;
     多个form区分可以用name或者id;
     select 中的option往后台传值的时候,传的是value的值,如果没有value传递的是两个标签之间的值;