-3

I am trying to make the button in my form contain two names. Let me explain.

I have 2 buttons, the first one has a value of 1, and the other one has a value of 2. They are both connected to the post method "Click". But I need my "$pos = $_POST['position']" to become the value of the button. Is that possible?

What I tried was <button name="click" name="position" type="submit"> but it's not working

Omega Cebbo
  • 17
  • 2
  • 7

1 Answers1

4

No element can have two attributes with the same name (i.e. you cannot have two attributes named name on one element). Some attributes take a space-separated list of values, but name is not one of them.

Pick either click or position to be the name of the button, and change your server-side code so that it recognises data with that name as representing both pieces of information that you were trying to convey.

You'll probably want to add a value attribute too.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • How can I make my variable $pos equal the value of the button with only one attribute? – Omega Cebbo Dec 07 '17 at 19:15
  • @OmegaCebbo — `$pos = $_POST['XXX']` where XXX is whichever of the two names you pick. (Assuming the button is in a form with method=post) – Quentin Dec 07 '17 at 19:17