Consider a form with a single button of type "submit":
<button type="submit" id="formSubmitButton">Submit</button>
When loading the page, I send a GET-request to my server, which will return an object that is used to fill out the form. If there is no object inside my server-side database, the form will be empty. I have attached an EventListener to my form, such that when the form is submitted, a POST request is send to my server. I only want to send a post request, however, when the form was initially empty (on loading the page). If it wasn't, I want to send a PUT request instead. And I don't want to introduce another button inside my form. Else, I assume, I could just send the POST/PUT requests upon clicking on either buttton. I just want the single button though.
Does anyone know of a nice way to accomplish this?