Forum Moderators: coopster
textbox1row1, textbox2row1, textbox3row1
textbox1row2, textbox2row2, textbox3row2, etc.
I have this accomplished and can dynamically build this sort of structure to any length (and remove any elements).
how to get data from these form fields in php
please help me asap
thanks
For start, make sure all your textfields names, follow a logical patern: for example text1, text2, text3, text4...
Make sure that all your data are submited by your form
(check your submission page with something like:
echo "<pre>";
print_r($_POST);
echo "</pre>";
Now the tricky part:
put a hidden field into your form - this will be your textfield counter. Starting value is your minimum number of textfields (if your form has always 3 text fields, this counter will be 3 at default value).
In your java code you must add a function that increase your hidden counter whenever you "add" textfields to your form, or decrease it.
When you submit your form (and if the java part works correctly), loop through your textfields (since you know their exact number stored in your hidden counter)
something like:
for ($i=1;$i<=$hidden_counter;$i++)
{
$my_field = "textfield".$i;
$my_value = $$my_field;
if ($my_value!="")
{
// do something with your data
}
}
For start, make sure all your textfields names, follow a logical patern: for example text1, text2, text3, text4...
This would be the more difficult way to do this. You are much better off doing it like this:
<input type="text" [b]name="text[]"[/b] />
<input type="text" [b]name="text[]"[/b] />
<input type="text" [b]name="text[]"[/b] />
This way when you submit the form you already have these values in an array:
echo '<pre>';
[url=http://us2.php.net/print-r]print_r[/url]($_POST['text']);
echo '</pre>';
Good luck :)