Get all option-values from a multi-select
Posted: Thu Sep 03, 2009 11:23 pm
Hello Everybody!
I'm pretty new to php(second day) so please be kind. :/
I have two select boxes that I can move options between(javascript) I populate the right box
with options from the left then the goal is to press submit and send the options in the right box to a php script.
The problem I'm having is that the script "test.php" only receives the option elements that are selected(go figure)
Is there a way of using $_POST to get all the option values in the right hand box(not selected)?
An example....
The html file.
The php file. This would echo only echo values that are selected.
Thanks in advance!!
I'm pretty new to php(second day) so please be kind. :/
I have two select boxes that I can move options between(javascript) I populate the right box
with options from the left then the goal is to press submit and send the options in the right box to a php script.
The problem I'm having is that the script "test.php" only receives the option elements that are selected(go figure)
Is there a way of using $_POST to get all the option values in the right hand box(not selected)?
An example....
The html file.
Code: Select all
<html>
<head></head>
<body>
<form action="test.php" method="POST">
<select name="OS[]" size="5" multiple>
<option>Windows</option>
<option>Linux</option>
</select>
<input type="submit" name="send">
</form>
</body>
</html>Code: Select all
<?php
foreach($_POST['OS'] as $key=>$value) {
echo $key.' '.$value;
}
?>