tags:

views:

20

answers:

1

hi,

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.

Thanks.

+1  A: 

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

Dan Heberden
thank you it is done well the hidden type resolve perfectelly the problem it is quite nice from you .thanks again you saved my time.
kawtousse