Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

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
Trades: 0
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

Please login or register to view this content. Registration is FREE

Great hosting at affordable pricing!
capetek is offline
Reply With Quote
View Public Profile Visit capetek's homepage!
 
 
Register now for full access!
Old 09-25-2007, 11:09 AM Re: Select box into an array
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
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
}
?>
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE

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
Trades: 0
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

Please login or register to view this content. Registration is FREE

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 Search this Thread
Search this Thread:

Advanced Search

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

BB 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.11909 seconds with 12 queries