Richard Korts
asked on
Multi-select select list - process in php
If you have a form with a select element with multiple selections allowed, how do you process the selections in the php form processing program?
If the form element is called "choices", in the php program how to I separate out the individual choices made?
Thanks
If the form element is called "choices", in the php program how to I separate out the individual choices made?
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
A 'GET' version works as well. Save this one as 'multiselectget.php'.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Multi-select select list in php</title>
</head>
<body>
<h1>Multi-select select list in php</h1>
<form action="" method="post" enctype="multipart/form-data">
<select name="sometext[]" id="sometext" multiple="multiple">
<option value="1">text1</option>
<option value="2">text2</option>
<option value="3">text3</option>
<option value="4">text4</option>
<option value="5">text5</option>
<option value="6">text6</option>
</select>
<input type="submit" name="submit" value="Submit" />
</form>
<pre>
<?php
if(isset($_REQUEST['submit'])) {
echo "<b>GET</b><br>";
var_dump($_GET);
echo "<br><b>POST</b><br>";
var_dump($_POST);
echo "<br><b>REQUEST</b><br>";
var_dump($_REQUEST);
}
?>
</pre>
<br />
<a href="multiselectget.php">multiselectget.php</a>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In the action script you can learn about what the form sends by using var_dump($_REQUEST)