Page 1 of 1

Iv got a problem with a multiple select form

Posted: Tue Jul 11, 2006 4:19 am
by AshrakTheWhite
Hey good day chaps :)

Can anyone explaine to me how to make a multy select form return the selected option ID's or whatever to diferentiate them from eachother aka if i select o1 and o4 the POST would return me those values

Code: Select all

<SELECT MULTIPLE SIZE=5>
 <OPTION VALUE="o1">Option 1
 <OPTION VALUE="o2">Option 2
 <OPTION VALUE="o3">Option 3
 <OPTION VALUE="o4">Option 4
 <OPTION VALUE="o5">Option 5
 <OPTION VALUE="o6">Option 6
</SELECT>

Posted: Tue Jul 11, 2006 4:44 am
by shiznatix
first, you gotta give it a name. second you gotta make the name an array, because you will want an array from that name. third, use the multiple="multiple" as the other way is depreciated or somthin. this works:

Code: Select all

<select name="test[]" multiple="multiple">
	<option value="one">one</option>
	<option value="two">two</option>
	<option value="three">three</option>
	<option value="four">four</option>
	<option value="five">five</option>
</select>

Posted: Tue Jul 11, 2006 5:11 am
by jeeep
I'm having somewhat the same problem. Can I do this to this:

Code: Select all

<select name="test[]" multiple="multiple">
   <option value="/teamspeakimg.png">Image1</option>
   <option value="/teamspeakimg2.png">Image2</option>
   
</select>
to select a pic. for this php file

Code: Select all

$test = $_POST['test'];
$test=array();
$image1=$test[];
(Not really sure how to do it properly in the php file)

Posted: Tue Jul 11, 2006 5:21 am
by Benjamin
A great way to "look" at what is being posted is to put this code in the page you are posting to. Look at what is being posted and play around with it.

Code: Select all

echo '<pre>';
print_r($_POST);
echo '</pre>';

Posted: Tue Jul 11, 2006 5:23 am
by JayBird
jeeep wrote:I'm having somewhat the same problem. Can I do this to this:

Code: Select all

<select name="test[]" multiple="multiple">
   <option value="/teamspeakimg.png">Image1</option>
   <option value="/teamspeakimg2.png">Image2</option>
   
</select>
to select a pic. for this php file

Code: Select all

$test = $_POST['test'];
$test=array();
$image1=$test[];
(Not really sure how to do it properly in the php file)
Like this

Code: Select all

$images = $_POST['test'];
foreach($images as $temp)
{
    echo $temp;
}

Posted: Tue Jul 11, 2006 5:42 am
by jeeep
awesome ty!