What is the role of the attribute name = "..." in the input?

In this form of code, what is the role of the attribute name=""?

name="s"and name="submit".

Do I need to add?

<form action="/index.php" method="get">
   <fieldset>
    <legend>Search</legend>
    <label for="s"><span>Search WaSP</span>
    <input value="" name="s" id="s"></label>
    <input type="submit" value="Go!" name="submit" >
   </fieldset>
  </form>
+3
source share
3 answers

In the request form

< name( "control name" ) is passed to the query string. This is different from the attributeid that is used to uniquely identify an UA element (browser).

With the namerequest will look like

/index.php?s=&submit=Go!

Without a namerequest, it will look like

/index.php
+7
source

This is what is actually sent to the server, like a name in the usual submit form.

. StackOverflow -, , , -.

GET /x -www-form-urlencoded POST (name = value).

0

This is how they are represented in the DOM.

document.forms [0] .s.value

0
source

Source: https://habr.com/ru/post/1746817/


All Articles