zoukankan      html  css  js  c++  java
  • html name id, 与服务器交互必须有name

    html name id, 与服务器交互必须有name

    在HTML中元素的ID和Name的区别和联系。
    今天写了个测试,在php脚本里怎么也获取不到$_POST['userName']的值,经检查在html页面只写了input的Id,没有写Name。

    现总结网上的帖子:

    Name Attribute

    Valid only on a, form, iframe, img, map, input, select, textarea
    Name does not have to be unique
    Can not be referenced in URL
    Is referenced in JS with getElementsByName()
    Shares same name space as id attribute
    Must begin with a letter
    Is case sensitive
    Used on form elements to submit information

    Id Attribute

    Valid on any element
    Each Id should be unique
    Can be used as anchor reference in URL
    Is referenced in CSS or URL with # sign
    Is referenced in JS with getElementById()
    Shares same name space as name attribute
    Must begin with a letter
    Is case sensitive

    参考: 1 http://stackoverflow.com/questions/7470268/html-input-name-vs-id 
    2 http://www.cnblogs.com/birdshome/archive/2005/01/31/99562.html
  • 相关阅读:
    区间K 大数查询
    最大最小公倍数
    吃糖果
    身份证号码升级
    威威猫系列之 吃鸡腿
    小Q系列之失恋
    查询7天之内的数据
    WebService案例 Spring boot+CXF开发WebService Demo
    开发过程中遇到问题
    oracle 自增序列 sequence
  • 原文地址:https://www.cnblogs.com/timssd/p/4781145.html
Copyright © 2011-2022 走看看