Reply
Select box into an array
Old 09-25-2007, 08:37 AM Select box into an array
capetek's Avatar
Extreme Talker

Posts: 229
Location: Massachusetts
Ok,

Well im trying to make a multiple selectbox into an array exactly like you can do with checkboxes. But for some reason its not working. I set the name to pages[] which should turn all selected values into an array on process. Can you not do this with selectboxes? Anyone know a solution?

PHP Code:
<select size="6" id="selectedOptions" name="selectedOptions[]" style="width:300px" multiple>
                    
<
option value="7">For-Businesses</option>
<
option value="15">For-Consumers</option>
<
option value="1">Home</option>
</
select
__________________
Anthony LeBoeuf
Cape-Tek IT Solutions
www.cape-tek.com
Great hosting at affordable pricing!
capetek is offline
Reply With Quote
View Public Profile Visit capetek's homepage!
 
When You Register, These Ads Go Away!
Old 09-25-2007, 11:09 AM Re: Select box into an array
rogem002's Avatar
Webmaster Talker

Posts: 611
Name: Mike
Location: United Kingdom
Well, I assume it should come back as an array anyway. Try the below.

Change your code to:
HTML Code:
<select size="6" id="selectedOptions" name="selectedOptions" style="width:300px" multiple>
                    
<option value="7">For-Businesses</option>
<option value="15">For-Consumers</option>
<option value="1">Home</option>
</select>  
Then with PHP, use:
PHP Code:
<?php
$selectedOptions 
$_POST['selectedOptions'];
//$selectedOptions  should be an array if more than one is selected. I think.

if(is_array($selectedOptions)){
// More than one was selected
} else {
// Only one or none were selected
}
?>
__________________
PHP Code:
Add_Talkupation('rogem002'); // Because sharing is awesome! 

Last edited by rogem002 : 09-25-2007 at 11:18 AM.
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 09-25-2007, 01:17 PM Re: Select box into an array
capetek's Avatar
Extreme Talker

Posts: 229
Location: Massachusetts
Yep thanks it was actually my fault, I had it running through a stripslashes function which was messing it up somehow
__________________
Anthony LeBoeuf
Cape-Tek IT Solutions
www.cape-tek.com
Great hosting at affordable pricing!
capetek is offline
Reply With Quote
View Public Profile Visit capetek's homepage!
 
Reply     « Reply to Select box into an array
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12541 seconds with 12 queries