Need help with dynamically created form fields and $_POST
Posted: Mon Mar 29, 2010 5:40 pm
Okay, I'm really new at this and need some help.
I wrote a javascript script that creates form fields dynamically (onClick button) and appends a number to their ID, so each newly created field has a unique ID. I'm using POST to pass the values of these fields. So far I have only been able to get the script to tell me how many fields were created. Now I'm stuck here.
The ultimate goal that I need to reach is for the script to recognize how many fields were created and create a unique variable for each field that holds the value of what ever was entered into each respective form. and then creating a variable that holds all those variable's as a string with HTML line breaks in it so that it can be read correctly when echo'd or emailed
I have no idea how to do this and have been messing with it for more than 8 consecutive hours now. Here is what I have so far and honestly. I have no idea how I even got this far, I'm just learning PHP now.
any help is appreciated here, I'm not asking you to write it for me, but just a push in the write direction. Thanks.
EDIT:
I think I got it.
But now my issue is that I need to email this info. I can of course write something like this:
but that's just sloppy and far from elegant. There has to be an easier way to do this, and one that doens't have a limitation based on how many times I feel copy and pasting that.
I wrote a javascript script that creates form fields dynamically (onClick button) and appends a number to their ID, so each newly created field has a unique ID. I'm using POST to pass the values of these fields. So far I have only been able to get the script to tell me how many fields were created. Now I'm stuck here.
The ultimate goal that I need to reach is for the script to recognize how many fields were created and create a unique variable for each field that holds the value of what ever was entered into each respective form. and then creating a variable that holds all those variable's as a string with HTML line breaks in it so that it can be read correctly when echo'd or emailed
I have no idea how to do this and have been messing with it for more than 8 consecutive hours now. Here is what I have so far and honestly. I have no idea how I even got this far, I'm just learning PHP now.
Code: Select all
$getURLnumber = array();
$urlValue = $_POST['numberofurl'];
while($urlValue > 0)
{
$i++;
$URL = 'URL';
$getURL = $URL.$i;
$getURLnumber[] = $_POST[$getURL];
$urlValue--;
}EDIT:
I think I got it.
Code: Select all
foreach ($getURLnumber as $permURL)
{
$p++;
$URL.$p = $permURL;
}Code: Select all
$URLall = $URL. '<br><br>' .$URL1. '<br><br>' .$URL2. '<br><br>' .$URL3. '<br><br>' .$URL4. '<br><br>' .$URL5. '<br><br>' .$URL6. '<br><br>' .$URL7. '<br><br>' .$URL8. '<br><br>' .$URL9. '<br><br>' .$URL10. '<br><br>' .$URL11. '<br><br>' .$URL12. '<br><br>' .$URL13. '<br><br>' .$URL14. '<br><br>' .$URL15. '<br><br>' .$URL16. '<br><br>' .$URL17. '<br><br>' .$URL18. '<br><br>' .$URL19. '<br><br>' .$URL20. '<br><br> This Message was sent to you from: ' .$email;