The difference between name and value in input tag

The difference between name and value in input tag
type is the control used for input and output in the browser (for example, type="text" means a text box; type="button" means a button)
The optional values ​​of type are as follows:
button
checkbox check button component
file file upload component
hidden hidden field
image image area
password Password input text box
Radio button component
reset reset form button
submit Submit form button
text text input box
*******************************************************************************
id is a unique identifier and does not allow duplicate values ​​(similar to the primary key of a data table, pk). Its value can be used to obtain the corresponding html tag object. (If duplicate ids appear in the same page code, unexpected errors will occur)
js code: document.getElementById("id_value")
Get the object reference of the specified id.
*******************************************************************************
The functions of name and id are the same, and they are also used to identify HTML tags, but the only difference is that name allows repeated values.
js code: document.forms[0].name or document.getElementsByName("name")
Get the object reference array according to the specified name.
*******************************************************************************
value represents the value of a certain html tag. For example: <input type="text" name="seq" value="hello!" id="seq007" />
You will see the content of the text box on the web page is "hello!"
///////////////////////////////////////////////////////////////////////
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script>

</script>
</head>
<body>
<form>
<input type="text" name="seq" value="" id="seq001" />
<input type="text" name="seq" value="" id="seq002" />
<input type="text" name="seq" value="" id="seq003" />
</form>
</body>
</html>
///////////////////////////////////////////////////////////////////////
document.getElementById("seq001") obtains the reference to the object tag with id=seq001
document.forms[0].seq
Will return an array of references to all tag objects with name=seq in the first form on the web page
document.getElementsByName("seq")
Will return an array of references to all tag objects with name=seq in the web page

<<:  Summary of 7 types of logs in MySQL

>>:  Use a diagram to explain what Web2.0 is

Recommend

What are the core modules of node.js

Table of contents Global Object Global objects an...

You may need a large-screen digital scrolling effect like this

The large-screen digital scrolling effect comes f...

How to use Antd's Form component in React to implement form functions

1. Construction components 1. A form must contain...

How to read the regional information of IP using Nginx and GeoIP module

Install GeoIP on Linux yum install nginx-module-g...

Getting Started Tutorial for Beginners⑧: Easily Create an Article Site

In my last post I talked about how to make a web p...

A Brief Analysis on the Time Carrying Problem of MySQL

The default time type (datetime and timestamp) in...

Analysis of the principle of using PDO to prevent SQL injection

Preface This article uses pdo's preprocessing...

4 ways to optimize MySQL queries for millions of data

Table of contents 1. The reason why the limit is ...

Tutorial diagram of installing TomCat in Windows 10

Install TomCat on Windows This article will intro...

Steps to deploy Spring Boot project using Docker

Table of contents Create a simple springboot proj...

Memcached method for building cache server

Preface Many web applications store data in a rel...

MySQL uses find_in_set() function to implement where in() order sorting

This article introduces a tutorial about how to u...

Detailed steps to install the NERDTree plugin in Vim on Ubuntu

NERDTree is a file system browser for Vim. With t...

Detailed explanation of docker nginx container startup and mounting to local

First, the structure inside the nginx container: ...

JavaScript canvas to achieve colorful clock effect

Use canvas to write a colorful clock! 1. Title (1...