![]() |
php form submit only data that was used
I am creating a scoring system for deer and I have a form that asks for the measurements. I also have an option that adds more forms (if the deer has more than 4 tines, or 4 abnormal points). Now when I submit my form it sends it a /add.php. I have it so it displays the original forms and then I want to make it so it shows the addition forms. BUT only if they used that form. So basically I want it to display the measurement in the fields ONLY if they were used.
Code:
<?phpCode:
<table width="400" id="file_d" style="display:none" cellspacing="0" cellpadding="0" border="0">Code:
<input type="text" name="pp">I am wanting to display the original fields (a,b,c,d,etc..) and then if someone had clicked "add more" and entered in another field. I want that field to be displayed as well (aa,bb,cc,etc...) I tried something like Code:
<?phpI dont know much about php so any help would be appreciated |
You actually want to use arrays for these. You can name them if you want, but if the name's have no actual value by themselves, than a list is what you'll get.
PHP retrieves arrays from html with the following conventions: <input type="text" name="yourname[specificoffset]" /> where you can now find the value in $_POST['yourname']['specificoffset']. If no specific is required, than a simple [] will suffice. 'yourname' is whatever you want to call it.Then in processing you simply sum them up: PHP Code:
Naming them is useful if you want to display some info for them. You can retrieve that from the key() of the array during iteration, or $key from the foreach: PHP Code:
This works well with JS as well as you can create the item with the same naming convention and append it to the dom forms. |
As for the part you tried, Fou-Lu's way is easiest
PHP Code:
|
| All times are GMT +1. The time now is 11:52 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.