I've readed a nice tutorial how to add more form inputs with a button.
It works fine thanks.
I have a question for the following concept:
drop down: number of guests:
in the php it has to read the dropdown value and this value has to be -1.
Help is welcome!!
Matteo
Hi Matteo,
Sorry, but I don't understand your question :-(
Bob
So, a dropdown ( named guests) where I choose how many guests.
Then the code has to do $count = guest - 1
HI Mattteo,
The code you've posted is PHP which runs before the form loads.
If you want to make a change based on a selection by the user in the browser than you either have to add it using JavaScript, or you have to submit and then reload the form with the amended values.
Bob
Hi vismay,
Good, you will need to add to this to make the changes you need.
Bob
Yes, it works.
But only for a fixed number of guests set from: $count = 5;
I need to have this variable according to the previus dropdown.
HI vismay,
Then edit the code to check the value of the drop down and add that number of new entries, the same basic code should work OK.
Bob
Hi Vismay,
The PHP to set the number of input boxes runs before the page loads and so you can't change it from a drop-down setting after the page loads.
You can either (a) split the form in two parts - with the first setting the number of 'ospiti' and the second showing the matching number of inputs or (b) use JavaScript to change the number of inputs depending on the drop-down setting.
The first of these is simpler if you don't have JavaScript expertise available.
Bob
Hello,
in relation with all this discuttion, I would like to create a table for my form.
As there are variable like:
recipient[{$i}][name]
etc...
The systyem says:
Field name "recipient[{$i}][name]" is invalid, please fix the field name in the wizard (or the form code) then retry again.
Field name "recipient[{$i}][cognome]" is invalid, please fix the field name in the wizard (or the form code) then retry again.
A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.
Can I avoid this problem?
Thanks
It is something like:
recipient_1_name
recipient_2_name
recipient_3_name
etc.... repeated as many times as the maximum planned?
COuld i do it manually in the database?
Hi vismay,
I can't tell what you are doing from your posts here. If you are using the code from the example then the {$i} will be replaced with 1, 2, 3, etc.
Bob