This topic is locked
[SOLVED]

 Multiple Selection Drop Down Box

10/24/2014 6:44:48 PM
PHPRunner General questions
S
stiven author

Hello,
I have been looking online and here in this forum with no luck. I am wondering if it is possible on a dropdown box with the option to allow multiple selection, force or limit the selection to 3 items?
I hope this makes sense, thank you! I found this online but I was not able to implement it in PHPRunner



$('#slectboxid option').click(function()

{

var items = $(this).parent().val();

if (items.length > 3) {

alert("You can only select 3 values at a time");

$(this).removeAttr("selected");

}

});
admin 10/24/2014

You can make it work if you use correct control ID instead of "slectboxid". You can look it up using Firebug or Chrome Developer Tools.

S
stiven author 10/27/2014

I tried the correct control id I think this is what I've tried an hasn't worked :/


$('#value_fine_motor_item_1 option').change(function()

{

var items = $(this).parent().val();

if (items.length > 3) {

alert("You can only select 3 values at a time");

$(this).removeAttr("selected");

}

});
$('#value_fine_motor_item_1 option').click(function()

{

var items = $(this).parent().val();

if (items.length > 3) {

alert("You can only select 3 values at a time");

$(this).removeAttr("selected");

}

});
$('#value_fine_motor_item_1').change(function()

{

var items = $(this).parent().val();

if (items.length > 3) {

alert("You can only select 3 values at a time");

$(this).removeAttr("selected");

}

});
$('#value_fine_motor_item_1').click(function()

{

var items = $(this).parent().val();

if (items.length > 3) {

alert("You can only select 3 values at a time");

$(this).removeAttr("selected");

}

});


None of these work nor there is any javascript errors on the page :/

C
cristi 10/27/2014

You can use this: http://ivaynberg.github.io/select2/
The maximum and minimum selection limit is already implemented :

Select2 allows the developer to limit the number of items that can be selected in a multi-select control. In the example below only 3 or less items can be selected.

admin 10/28/2014

Stivens,
if you have a valid support contract post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.

S
stiven author 10/29/2014

Here is the solution for whoever might need it, Although it is not removing the last selected item from the dropdown box it is letting you know you should only select 3 items at a time



$("#value_fine_motor_item_1").change(function(){



var items = $("#value_fine_motor_item_1").val();

if (items.length > 3) {

alert("Please select only 3 items at a time");

$("#value_fine_motor_item_1").prop("selected", false);

}

});