button submit with 2 different behaviour
how could i set a variable with a submit button in order to differenciate 2 behaviours, so first time the same submit button will insert in database and in second time it updates database values.
Th开发者_开发知识库anks.
Depends on your implementation, and if it's ajax..
If ajax, you want to make a note of the fact it's an update somewhere.. perhaps a form element that says so?
<input type="hidden" id="formUpdate" value="0" />
and on the first submit
document.getElementById('formUpdate').value = 1; // and on the submit, check if it's 0 or 1
If posting to the server, you can include the in the code so when the form is submitted again, you can access $_REQUEST['formUpdate'] (such as with php, anyway) ..
hope that helps ya
精彩评论