Phpster wrote:
On Apr 10, 2009, at 12:44, Al <news@xxxxxxxxxxxxx> wrote:
PJ wrote:
I have a script with $_POST and <form> to load data with text input.
Situation: enter name of author(s) for book. I have the script set up to
enter first_name, last_name for Author1 and the same for Author 2.
Check if entry 1 exists then proceed accordingly
Check if entry 2 exists then proceed accordingly.
Now, If I have three or more authors to enter, is there a way to add a
radio button to add more rows for input or to skip further inputs, if I
have to enter the inputs for each additional author?
I'm looking for a simple way to do this. Could or should Ajax be
involved in this somehow?
Here's the way I do it, especially if typically the number of entries
are small. e.g., 4 or so.
Show the 4 and let the user Submit them.
Then, if they used all 4, return the page with an additional 4. Show
all 8.
Then, if they've used all 8, repeat until they leave at least one
unused. Process the page.
Make the batch size a constant that you can easily change. And
consider making the first rendering say 6 and subsequent additions 3,
or whatever.
If you want to get a little fancy. Make a simple log file for the
total number of entries. After the application has been used for a
while, you can check the log and adjust your batch size constant(s)
accordingly.
Al....
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Why, why make trips to the server when you don't need to?
I agree.
Write a simple javascript that creates an input and adds it as a child
to the node that contains your inputs.extension) and replace it with a
virgin input.
var someInput = document.createElement("input");
someInput.setAttribute("type","file");
someInput.setAttribute("name","voucher[]");
someInput.setAttribute("style","width: 42em;");
myDiv.appendChild(myImage);
Put something like that in a function where myDiv is the parent div of
your inputs.
Then you can add as many extra inputs as you want client side by calling
the function and there is no need to mess with ajax or any other server
side tech.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php