php form select option
Moderator: General Moderators
php form select option
I am trying to create a form. the first form is a select options that choses from 5 options. When i person selects one, another select option form opens with different options reference to the first form. Not sure how to do this. I know it would be if($submit)
{ if ($firstform == option1) { new select form }
if ($firstform == option 2 { new select form }
Not sure how to go around it and if it will work
Many thanks
{ if ($firstform == option1) { new select form }
if ($firstform == option 2 { new select form }
Not sure how to go around it and if it will work
Many thanks
Hotscripts
Can this Javascript from Hotscripts be what you are looking for?
http://www.hotscripts.com/Detailed/7976.html
http://www.hotscripts.com/Detailed/7976.html
-
tylerdurden
- Forum Commoner
- Posts: 66
- Joined: Mon Jul 28, 2003 11:52 am
- Location: Austria
I've put up an example for you at http://www.titleofsite.com/foo.html Go check it out, it's quite simple. You can also easily create the required arrays with PHP.
Hmm. After re-reading your post I'm not sure if this will help you at all
If you really want to go to a new page after the user selects an option you'll simply have to change a (hidden) form field to the value the user selected:
and in the leapto function add
where intodb is the name of the hidden form field.
Hmm. After re-reading your post I'm not sure if this will help you at all
If you really want to go to a new page after the user selects an option you'll simply have to change a (hidden) form field to the value the user selected:
Code: Select all
var values = new Array();
valuesї1] = "Value1";
valuesї2] = "Value2";
valuesї3] = "Value3";Code: Select all
form.intodb.value = valuesїmyindex+1];hey
thanks for that
i know u said it was simple but i am confused
So i want for select1 options For the family
For the garden
For the Home
I put them in the values as i want the chosen one to be inserted into database
Lets say, a user selects for the family
and in the select2 i would have For him
FOr her
For kids
For Babies
For Pets
, been trying to change it to them, but a bit confused
Sorry abuot this. Many thanks
Not that bothered about going to another page. This option looks the easiest way
thanks for that
i know u said it was simple but i am confused
So i want for select1 options For the family
For the garden
For the Home
I put them in the values as i want the chosen one to be inserted into database
Lets say, a user selects for the family
and in the select2 i would have For him
FOr her
For kids
For Babies
For Pets
, been trying to change it to them, but a bit confused
Sorry abuot this. Many thanks
Not that bothered about going to another page. This option looks the easiest way
-
tylerdurden
- Forum Commoner
- Posts: 66
- Joined: Mon Jul 28, 2003 11:52 am
- Location: Austria
If you want to put "For the garden" into your db and not an associated value like "1" you'll have to use an associative array. Look at http://www.titleofsite.com/foo2.html.
-
tylerdurden
- Forum Commoner
- Posts: 66
- Joined: Mon Jul 28, 2003 11:52 am
- Location: Austria
Yes, you need 1 array for the values and 1 for the labels. Since in your case label and value are the same you could also use
and leave out the myLabels array,
and later in the function use:
BTW: To prevent anyone from getting hurt I have to mention that I copied this code from some tutorial (who's URL I can't remember) and adapted it for my needs.
Code: Select all
myValuesї"For the family"] = new Array("FOr her","FOr kids","For babies","for pets")and later in the function use:
Code: Select all
fld.optionsїi] = new Option(myValuesїst]їi]);-
tylerdurden
- Forum Commoner
- Posts: 66
- Joined: Mon Jul 28, 2003 11:52 am
- Location: Austria