0

Say I have a button like

<form action="/action1" method ="post">
<button type="submit" id="button1"> Click Me </button>
</form>

I want to get a value stored in the attributes (in this case "id") and do something like this

app.post('/action1', function (req, res) {
var buttonId = req.id // this is the part I dont understand
});

how would I fill in the line

var buttonId = 

Thank you

user2770808
  • 347
  • 3
  • 14

1 Answers1

0

The posted data does not include the id attribute. You can set the name and/or the value attribute and those will be part of the POST request. e.g.

<button type="submit" name="button1">Click Me</button>

To get to the posted data in express look here: Express js form data

Community
  • 1
  • 1
Vincent Schöttke
  • 4,416
  • 2
  • 12
  • 12