|
-
Feb 2nd, 2004, 03:46 PM
#1
Thread Starter
Fanatic Member
Simple question about drop-down boxes
If I want to have an option in a drop down box that selects more than one value (equivalent to multiselecting what do I do?
So if the code is currently
PHP Code:
<form action="<?php echo $PHP_SELF ?>" method="post">
<select multiple size=5 name="multiselect[]">
<option value="one">1</option>
<option value="two">2</option>
<option value="three">3</option>
<option value="four">4</option>
<option value="five">5</option>
</select>
And I want an option that selects 4 and 5 at the same time
PHP Code:
<form action="<?php echo $PHP_SELF ?>" method="post">
<select multiple size=5 name="multiselect[]">
<option value="one">1</option>
<option value="two">2</option>
<option value="three">3</option>
<option value="four">4</option>
<option value="five">5</option>
<option value="four and five">4&5</option>
</select>
Does not give the desired result. What should the syntax be?
-
Feb 2nd, 2004, 03:52 PM
#2
Well, I don't think you can have multi select in a drop down.... but you can in a listbox.
Ans as for selecting an option...
Code:
<option value="four" selected>4</option>
<option value="five" selected>5</option>
But that's only going to work once the list box is created (ie, it isn't going to work on the drop down).
Tg
-
Feb 2nd, 2004, 03:58 PM
#3
Thread Starter
Fanatic Member
Originally posted by techgnome
Well, I don't think you can have multi select in a drop down.... but you can in a listbox.
Ans as for selecting an option...
Code:
<option value="four" selected>4</option>
<option value="five" selected>5</option>
But that's only going to work once the list box is created (ie, it isn't going to work on the drop down).
Tg
Thanks - but that doesn't do what I need
I didn't want to make the example too complicated but what I need is the ability to do this (which can't be done by pre-selecting)
PHP Code:
<form action="<?php echo $PHP_SELF ?>" method="post">
<select multiple size=5 name="multiselect[]">
<option value="one">1</option>
<option value="two">2</option>
<option value="three">3</option>
<option value="four">4</option>
<option value="five">5</option>
<option value="three and five">3&5</option>
<option value="four and five">4&5</option>
</select>
-
Feb 2nd, 2004, 05:40 PM
#4
so.. uhh, do you want to list out all of the possible combinations? or do you want to have multiple selections? or.. what? your description is very vague to me.
in a select drop down menu you cannot have multiple selections. you can use a listbox for that, though. to select something on load, do what techgnome told you.
-
Feb 4th, 2004, 11:19 AM
#5
Stuck in the 80s
Re: Simple question about drop-down boxes
Originally posted by Kzin
Does not give the desired result. What should the syntax be?
What is the desired result?
-
Feb 4th, 2004, 12:23 PM
#6
Thread Starter
Fanatic Member
Well the desired result is to have a single option that *acts* like a particular multiselection of options and another single option that acts like a different multiselection.
Like this (see last two options)
PHP Code:
<form action="<?php echo $PHP_SELF ?>" method="post">
<select multiple size=5 name="multiselect[]">
<option value="1">BBC Micro</option>
<option value="2">Apple II</option>
<option value="3">IBM AT</option>
<option value="4">Archimedes RISC5000</option>
<option value="5">VAX-11</option>
<option value="1&4">British Computers</option>
<option value="4&5">32-Bit Computers</option>
</select>
-
Feb 4th, 2004, 03:43 PM
#7
Stuck in the 80s
Originally posted by Kzin
Well the desired result is to have a single option that *acts* like a particular multiselection of options and another single option that acts like a different multiselection.
Like this (see last two options)
PHP Code:
<form action="<?php echo $PHP_SELF ?>" method="post">
<select multiple size=5 name="multiselect[]">
<option value="1">BBC Micro</option>
<option value="2">Apple II</option>
<option value="3">IBM AT</option>
<option value="4">Archimedes RISC5000</option>
<option value="5">VAX-11</option>
<option value="1&4">British Computers</option>
<option value="4&5">32-Bit Computers</option>
</select>
And why isn't it working for you? Your PHP variable would be $_POST['multiselect'][$i] = '4&5', which is exactly how you're coding it to be.
Do you want the results seperate, so you'll have $_POST['multiselect'][$i] = 4 and $_POST['multiselect'][$i] = 5?
If so, there's nothing you can drop in that form that will give you that. There's no way to do it, unless you write some javascript that reconstructs the array before submission, or write some PHP code that reconstructs the array after submission.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|