Hello. Tell me how in one input I can specify 2 values ​​of the name?

Trying to do so, but nothing works, does not work

<input type="text" placeholder="Телефон" name="phone" name="entry.1312741979">

I then get the value of the name="phone" field via $ _POST and write to the database.

The name="entry.1312741979" field name="entry.1312741979" I write in Google table.

Separately, name="entry.1312741979" and name="phone" works as soon as I register so <input type="text" placeholder="Телефон" name="phone" name="entry.1312741979"> only the first one is executed action, writing to the database, does not write the table to google

thank

  • one
    you can not. What is the meaning of this action? - teran
  • The point is to send data to a google table and write to a database in parallel. The entry in the Google table is done through entry.1312741979 and the entry in the database via the phone . And I need 2 name attributes, since I can't set $_POST['entry.1312741979'] - Ksenia
  • Found a way out on the Internet "if you create an Input field with the name Name containing a period in the form, the browser automatically replaces it with an underscore!" - Ksenia
  • Why not create a dictionary, where the keys will be the first names, and the values ​​corresponding to their middle names? phone -> entry.1312741979 - slippyk

2 answers 2

According to the HTML5 specification , you cannot have two exactly the same attributes in one tag. More precisely, you can, but the behavior will be undefined , the browser will probably only parse the first value, and ignore the second.

ASCII case-insensitive match for each other.

In order to send data to a third-party service with a different name format:

1) You can use special data- * attributes that allow you to process them via Javascript and send them to the server. For example, create a data-name attribute, first send your form to the database via Ajax, and then a little Javascript, get all the inputs with the data-name and send them to the second form, also via Ajax.

2) On the server side, use the harvested Mapper, which will convert the names of the names, such as phone, to entry.1312741979 and send further to the service via API.

    An input element cannot have 2 name attributes. Look here for all valid attributes.

    In your case, the most appropriate solution would be to create duplicate type = "hidden" inputs and a bit of jquery :

     <input type="text" placeholder="Телефон" name="phone" /> <input type="hidden" placeholder="Телефон" name="entry.1312741979" />