Ost Ost - 6 months ago 7x
Javascript Question

How to submit forms input values using post to server side script

I have a lot of buttons, each opens its form . How do I get the input value of form opened at the moment, and post it on my server, like post("/addOrders", valueOfinputs)?


<div class="rows">

<div class="row">

<button class="open">Buy</button>

<form id="myform" action="/index" method="post">
<div class="form-group">
<label for="exampleInputEmail1">Name</label>
<input type="namee" name ="name" >
<div class="form-group">
<label for="exampleInputPassword1">Phone</label>
<input type="phone" name = "phone" >

<button class="ave" >Close</button>
<INPUT type="submit" id = "submit" class = "close" value="Submit">
<!---- <button id="submit" class="close"></button>-->





try this,

    return null;

.serialize() will put all form elements data into the request

Also you need to give different id for different Forms submit button and you have to do the above code for each submit button

Hope this works for you.