How to send by POST only the selected items?

-2

I want to send by the POST method only the data that is selected, including the name of the input and the quantity, how could I do it? I'm working with PHP and HTML, the data is in charge of the database.

form code

    
asked by Sergio Cordova 16.10.2018 в 06:57
source

1 answer

-1

Assuming that the elements you have in a <form> , when you do the submit of the form only those elements that do not have the attribute 'disabled' will be sent in the request.

Therefore, if you do not want a data to be sent, put the input element disabled before sending it.

It occurs to me that you can do this when you validate the form in javascript.

On the other hand, if you are sending it with ajax, well in that case you have total control of what is sent and what is not, so it is only a matter of determining if you add the variable to the POST or not.

    
answered by 16.10.2018 в 15:09