Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Listbox - select one item only

Questions related to using nuBuilder Forte.
Locked
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Listbox - select one item only

Unread post by toms »

Hi,

I want the user to select only one item at the same time in a select object (listbox). How do I disable the multiple selection? Is there an inbuilt way to do this?

Basically it's an object (Type: Select) with Multiple: Yes (by setting this, I see more than one item at a time) but without the attribute "multiple."
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Listbox - select one item only

Unread post by admin »

toms,

Try this...

Code: Select all

function stop_multiple(t){

   var s = $("#" + t.id).val();

   for(var i = 1  ; i < s.length ; i++){
       $("#" + t.id + " option[value='" + s[i] + "']").remove();
   }

}

blur.PNG

Steven
You do not have the required permissions to view the files attached to this post.
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: Listbox - select one item only

Unread post by toms »

Steven,

Thanks for the response. In the meantime, I have figured out another way by removing the multiple="multiple" attribute and adding a size.
By doing this, you can't select more than one item.

Code: Select all

$('#myselect').removeAttr('multiple');
$('#myselect').attr('size','5');
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Listbox - select one item only

Unread post by admin »

toms,

Yes, that's a better answer.

Steven
Locked