Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Contributing Multiple Select 1

Status
Not open for further replies.

BiJae

Programmer
Oct 1, 2002
154
US
I have a form where I want the user to be able to one or all from a select form. I am using PHP to handle the form information. When I echo back the variable I am only getting the last value selected, i.e. when 1, 2, & 3 are selected I only get 3 posted. Below is a sample of the form I built to test.

<HTML>
<head>
<title>Brian's Playpen</title>
</head>
<body>
<form method='post' action=''>
<select name='brian' size =3 multiple>
<option value=1>one</option>
<option value=2>two</option>
<option value=3>three</option>
</select>
<input type='submit' name='submit' value='send data'></form>
<?
echo $brian;
?>
</body>
</html>

Is there something that has to be set in an ini file some where to allow multiple items to be sent? All the research I have done says that the field should be posted as a CSV field. Any suggestions on what is going wrong?
 
Found this on the web....
For more info, you can go to

The select multiple tag in an HTML construct allows users to select multiple items from a list. These items are then passed to the action handler for the form. The problem is that they are all passed with the same widget name. ie. <select name=&quot;var&quot; multiple>

Each selected option will arrive at the action handler as: var=option1
var=option2
var=option3

Each option will overwrite the contents of the previous $var variable. The solution is to use PHP's &quot;array from form element&quot; feature. The following should be used: <select name=&quot;var[]&quot; multiple>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top