I want to have a series of drop-down menus, where the first drop-down menu selects $card[1], the second selects $card[2], and so on.
Does anyone know how to do this (with php if necessary)?
Having a form, where the variables are elements of an array.
-
Age of Fable
- Posts: 54
- Joined: Fri Feb 19, 2010 6:37 am
Having a form, where the variables are elements of an array.
Easy to play - hard to survive. http://www.ageoffable.net
Re: Having a form, where the variables are elements of an array.
never done this with dropdowns, but at a guess label each select tag with the representing name..
<select name="card[1]">
</select>
<select name="card[2]">
</select>
etc...
then through php
$cards = $_POST['card'];
$card1 = $cards[1];
$card2 = $cards[2];
etc...
this is best guess in this scenario, but logic dictates it should work lol
<select name="card[1]">
</select>
<select name="card[2]">
</select>
etc...
then through php
$cards = $_POST['card'];
$card1 = $cards[1];
$card2 = $cards[2];
etc...
this is best guess in this scenario, but logic dictates it should work lol
New Site Coming Soon! Stay tuned 
Re: Having a form, where the variables are elements of an array.
read below.misread.
Last edited by Xaleph on Sat Jul 30, 2011 4:05 pm, edited 1 time in total.
Re: Having a form, where the variables are elements of an array.
Oh wait, i misread.
You can use the name attribute on selects.
Just use a global name for each select and add a number to it. Like
<select name="cards-1">
<select name="cards-2">
<select name="cards-3">
Now, in PHP you can use substring to get the number back.
$number = substr($post, 0,6);
if($number == 'cards-'){
$number = substr($post, 6); // is 1 or 2 or 3
}
You can use the name attribute on selects.
Just use a global name for each select and add a number to it. Like
<select name="cards-1">
<select name="cards-2">
<select name="cards-3">
Now, in PHP you can use substring to get the number back.
$number = substr($post, 0,6);
if($number == 'cards-'){
$number = substr($post, 6); // is 1 or 2 or 3
}