I'm trying to make a form for registering the participants to a biking contest. I need the form to generate an unique id number (manually by a button or automatically by onload) before submit the form. The registrant must see his generated contest number. I'd like the number to be 3 digits style and increasing from a chosen initial one. Also, all generated numbers must be unique and increasing. Is this possible ?
Forums
Increasing id unique number?
Hi alink,
Are you sure that you want it 'before' the form is submitted? What happens if they choose not to submit?
Is it OK if some numbers in the sequence are skipped over and not used?
Bob
Are you sure that you want it 'before' the form is submitted? What happens if they choose not to submit?
Is it OK if some numbers in the sequence are skipped over and not used?
Bob
Hi Grey!
Thanks for your reply. If somebody decide to not register, then nothing is happens. The new generated number will not be introduced in the database. Next time when somebody will register the script must check the database and generate the available next number. Anyway, if is to complicate this way, I will be very glad to know any other solution. Generating after submit will be also great.
Greetings!
Thanks for your reply. If somebody decide to not register, then nothing is happens. The new generated number will not be introduced in the database. Next time when somebody will register the script must check the database and generate the available next number. Anyway, if is to complicate this way, I will be very glad to know any other solution. Generating after submit will be also great.
Greetings!
Hi alink,
The simplest way is after the submission. Add a DB Save action to the form to save the information to a database table. After the DB Save ChronoForms adds the record id to the $form->data array (add a Debugger action temporarily to see exactly where it is). This will be an auto-incremented number that you can use for the unique id (you may need to pretty it up a it).
Bob
PS The problem with generating it when the form loads is that you have to 'reserve' the number somehow in case someone else loads the form at the same time; and you have to deal with the case where they don't then submit the form - or it is a web bot browsing the page.
The simplest way is after the submission. Add a DB Save action to the form to save the information to a database table. After the DB Save ChronoForms adds the record id to the $form->data array (add a Debugger action temporarily to see exactly where it is). This will be an auto-incremented number that you can use for the unique id (you may need to pretty it up a it).
Bob
PS The problem with generating it when the form loads is that you have to 'reserve' the number somehow in case someone else loads the form at the same time; and you have to deal with the case where they don't then submit the form - or it is a web bot browsing the page.
This topic is locked and no more replies can be posted.