• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiple selection dropdown entry

#1
[eluser]johnsimpson[/eluser]
Hi guys,

I have been trawling the forums all morning and cannot find the answer to my problem, I am hoping one of you may be able to point me in the right direction.

I am using CI and Rapyd for a CMS system I am building.

Basically on each page I want to allow the administrator to select which modules will appear on each page. I want to display the available modules (pulled from the db) in a dropdown menu box where the user can select more than one option.

I have got the system inserting data from a dropdown for one selection but I cannot find out how to set the dropdown to multiple selection and then insert the values into a db field.

Can anyone help me?

thanks
John

#2
[eluser]sandeep nami[/eluser]
I think u have to use html property like this
<select multiple="multiple" size="2">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>

All of the selected data can be accessed by using $_POST

#3
[eluser]johnsimpson[/eluser]
Hi thanks for your reply but thats not really what I mean.

I am using the following code to insert/capture the information

$edit->test = new dropdownField("TEST", "modules");
$edit->test->style = "margin-top:0px; width:155px";
$edit->test->option("0","None");
$edit->test->options(array(
"1"=>"Mod 1",
"2"=>"Mod 2",
"3"=>"Mod 3",
"4"=>"Mod 4"
));
$edit->test->rule = "required";

What I need to know is how I make this code accept multiple selections (i.e. add in the multiple=multiple) and then add the values into one db field.

any ideas?

thanks
John

#4
[eluser]gcc.programmer[/eluser]
Hi John,

I'm not sure what rapyd is, but I'll structure my answer in relation to codeigniter, along the lines of the previous answer which was in html.

$options = array(
"1" => "Mod1",
"2" => "Mod2",
"3" => "Mod3",
"4" => "Mod4"
);
echo form_multiselect("TEST[]", $options, $selected="1");

This should create:
<select name="TEST" multiple="multiple">
<option value="1" selected="selected">Mod1</option>
<option value="2">Mod2</option>
<option value="3">Mod3</option>
<option value="3">Mod4</option>
</select>

Is this what you're asking?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.