Page 1 of 2
form wilt multiple form names not sending
Posted: Thu May 10, 2007 5:18 pm
by izzysanime
Hi,
I love you guys, you are always helpful, I appreciate it ^_^
I have a js script that the user can choose how many cars they are shipping, so Im not sure if thats the issue. But my issue is, that some of my form fields do not get sent. Everything else that is out of the script gets taken in to my DB. The forms name or IDs are the same, so i dont quite understand. Any ideas? The address is
http://wareriver.com/clients/fs/form.html
this is how its setup.
if they choose 1, gets one car (names are just vehicleVIn, etc)
if they choose 2, they have to cars (names are now vehicleVin & vehicleVin2)
and so on. but no mater if they choose 10, the first field is still named vehicleVin.
thanks
josh
Re: form wilt multiple form names not sending
Posted: Thu May 10, 2007 5:45 pm
by Kayin
Your description was a little ambiguous but that's understandable, you're problem isn't that easy to describe.
From what I can tell.....
Your javascript does not create new form fields, it simply makes them visible to the user. This means EVERYTIME the form is submitted, ALL of the fields should be present in the $_POST array.
I would bet money that your problem is in your process.php file.
To test this, at the beginning of your process.php put:
That'll dump everything that was submitted, onto the screen.
-K
Re: form wilt multiple form names not sending
Posted: Thu May 10, 2007 5:52 pm
by izzysanime
Which is nothing in that area, It seems that the vehichleVin in menu choice 10 over writes the vehicleVin in choice 2. So i suppose I would have to either make unique IDs for all of them, or always display 10? No other way?
This is what I got
Array ( [form_tools_form_id] => 8 [agentLastName] => 7 [agentFirstName] => 7 [customerInfoBusiness] => 77 [email] => 77 [customerInfoLastName] => 7 [customerInfoFirstName] => 77 [customerInfoAddress] => 7 [customerInfoCity] => 77 [customerInfoState] => 7 [customerInfoZip] => 7 [customerInfoPhones] => 77 [customerInfoPayment] => COD [dropmsgoption] => 2 [vehicleVIN] => [vehicleYear] => [vehicleMake] => [vehicleModel] => [vehicleColor] => [vehicleVIN2] => [vehicleYear2] => [vehicleMake2] => [vehicleModel2] => [vehicleColor2] => [vehicleVIN3] => [vehicleYear3] => [vehicleMake3] => [vehicleModel3] => [vehicleColor3] => [vehicleVIN4] => [vehicleYear4] => [vehicleMake4] => [vehicleModel4] => [vehicleColor4] => [vehicleVIN5] => [vehicleYear5] => [vehicleMake5] => [vehicleModel5] => [vehicleColor5] => [vehicleVIN6] => [vehicleYear6] => [vehicleMake6] => [vehicleModel6] => [vehicleColor6] => [vehicleVIN7] => [vehicleYear7] => [vehicleMake7] => [vehicleModel7] => [vehicleColor7] => [vehicleVIN8] => [vehicleYear8] => [vehicleMake8] => [vehicleModel8] => [vehicleColor8] => [vehicleVIN9] => [vehicleYear9] => [vehicleMake9] => [vehicleModel9] => [vehicleColor9] => [vehicleVIN10] => [vehicleYear10] => [vehicleMake10] => [vehicleModel10] => [vehicleColor10] => [pickupInfoBusiness] => 7 [pickupInfoLastName] => 7 [pickupInfoFirstName] => 7 [pickupInfoAddress] => 77 [pickupInfoCity] => 7 [pickupInfoState] => 77 [pickupInfoZip] => 7 [pickupInfoPhones] => 77 [deliveryInfoBusiness] => 7 [deliveryInfoLastName] => 7 [deliveryInfoFirstName] => 77 [deliveryInfoAddress] => 7 [deliveryInfoCity] => 7 [deliveryInfoState] => 7 [deliveryInfoZip] => 7 [deliveryInfoPhones] => 7 [specialInfo] => 7 [agree] => 777 [Submit] => Submit )
thanks again for your help
Josh
Re: form wilt multiple form names not sending
Posted: Thu May 10, 2007 6:09 pm
by Kayin
ah I see the problem in your HTML code. A bit table happy there?
Essentially, this is an example of what's going on:
You can't have multiple fields with the same name, even if one is "hidden" and the other isn't.
Instead of having 1 block with 1 row, a second block with 2 rows, third block with 3 rows.. etc.. have 1 block with 10 rows in it and have the javascript show one row at a time.
It's possible, though I think more difficult with tables.
-K
Re: form wilt multiple form names not sending
Posted: Thu May 10, 2007 6:30 pm
by izzysanime
I almost thought I knew what you meant, then I tried it, and realized it does not add, it replaces the 1 and ads 1 and 2. If you have a source that would allow me to do what you said, that would be great.
And yes, I now know that I cant use the same names.
Thanks
Josh
Re: form wilt multiple form names not sending
Posted: Fri May 11, 2007 4:53 pm
by Kayin
http://www.vrac.iastate.edu/~ewilder/test.html
Use that as an example, view source to see everything
It's simply a matter of searchin through w3schools.com...
-K
Re: form wilt multiple form names not sending
Posted: Fri May 11, 2007 5:15 pm
by Kayin
just a little fyi that I should've included in comments:
1. I wrote num2str because you can't have id's that are numbers. So..this was an alternative. Feel free to use a much simpler alternative, there are a few when u think about them.
2. Tested in IE7 and Firefox2. Which means they'll work on just about anything. I didn't test for w3 compatibility but w3schools verifies everything I used so I would assume its ok. It's table based afterall.
-K
Re: form wilt multiple form names not sending
Posted: Fri May 11, 2007 11:45 pm
by izzysanime
Awesome, thanks so much!
!!!! ^_^ You saved me from making 315 unique form ids 3 times. so 945 then.
I guess i should have studied JS in college, i skipped straight to PHP and Mysql.
learning something new every day.
If you need any PHP help, let me know... unless you already know PHP ^_^
Thanks a lot !!!
Josh
Re: form wilt multiple form names not sending
Posted: Mon May 14, 2007 4:22 pm
by Kayin
I didn't study javascript in college, or php, or mysql lol. they taught me java and the manner in which they taught me java was extremely painful, but allowed me to pick up virtually every other language I know in a matter of minutes.
-K
Re: form wilt multiple form names not sending
Posted: Tue May 15, 2007 5:34 pm
by izzysanime
O, ic
I now have another question for ya if thats ok. I need to auto fill some form fields, but in JS. I have it setup to do that in PHP, but i need it to happen before the pages is submitted.
Its just 6 text boxes that would need to be filled in with the exact same content that is in 6 other form boxes when the user clicks a button. Ive seen similar things on other sites, but it happens after they submit the page.
Thanks
Josh
Re: form wilt multiple form names not sending
Posted: Tue May 15, 2007 5:36 pm
by izzysanime
Well, I found a tutorial, after much rechecking, I finally got it working.
SO ya, thanks,
Josh
Re: form wilt multiple form names not sending
Posted: Thu May 17, 2007 4:01 pm
by izzysanime
How can i use this for a second drop down menu? I want to be able to use both, the one for 10 cars, but also a second drop down further down the page with separate things to get displayed. I tried adding
case 11:
return "eleven";
break;
case 12:
return "twelve";
break;
But, when i click on the second drop down menu it does nothing for the new 2, but does change the first one to showing 10.
Thanks again,
Josh
Re: form wilt multiple form names not sending
Posted: Thu May 17, 2007 7:01 pm
by Kayin
Read the javascript.. it counts up and displays each element one at a time for a given set of elements. If you want to use a different set, then define a different set, either using IDs, letters, or what it's up to you.
-K
Re: form wilt multiple form names not sending
Posted: Thu May 17, 2007 7:34 pm
by izzysanime
ok, here is what i modified, it kind of works, It ended up chaning the first set when i changed the second set menu. I changed the names. Now what it does, is make all of the first set stuff disappear and does nothing to the second set, the 2 show up.
function choose(x) {
var count = 1;
var str;
/* Resets all the fields to not show */
for(count; count
Re: form wilt multiple form names not sending
Posted: Thu May 17, 2007 7:45 pm
by Kayin
Why not just use a completely different number scheme
o_1
o_2
etc...
you can still increment by concatenating the counting number with whatever string you're using.
.... "o_"+count ....
Saves you from having the interpreter function too. (the big function with a switch)
-K