开发者

button submit with 2 different behaviour

开发者 https://www.devze.com 2022-12-31 17:46 出处:网络
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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号