...

View Full Version : Select Box POSTing



a_kerbouchard
01-08-2006, 02:23 AM
I have two select boxes I can Add and Remove the different Options between each of the select boxes. I am trying to submit this form and get all of the values of the Select box that I am adding to. Unfortunately I can't seem to get the information in the select box to go from one form to another. On the second form I use the $test = _POST['test'];. This works for all of the other types of form controls (text box, text area, checkbox, radio, etc), but not with the select box. Am I missing something?

I am using this format for the select box.

<select muliple=1 name=test><option></option><option></option></select>

Thanks

a_kerbouchard
01-08-2006, 03:43 AM
I ended up using hidden fields to save the value from the select box.

Thanks

missing-score
01-08-2006, 05:01 AM
you should use the post method, its much better as it wont require JavaScript (which is I'm assuming what you did). You have to do multiple select fields differently...



<form action="file.php" method="post">
<select name="test[]" multiple="multiple">
<!-- Notice the [] after the name -->
<option value="test1">test 1</option>
<option value="test2">test 2</option>
</select>
</form>




<?php

$test = $_POST['test'];
for($i=0; $i<count($_POST['test']); $i++ ){
echo $test[$i] . "<br />";
}

a_kerbouchard
01-08-2006, 06:58 AM
Thanks,

I did end up using javascript, took me a while because I kept mixing up my PHP and Javascript syntax. But I think the code you just listed will come in very handy. I wanted to use PHP as my solution in the first place.:)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum