Jump to content
  • 0

Multi-Select List Box


Elena
 Share

Question

Hi, 

 

Is there a way to put a limit to the number of items that can be selected in a list box? 

I have a list box in an update form. It is not for search purposes, rather for adding values to a data base.

 

Any help or attention will be greatly appreciated. 

 

Best, 

Elena

 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Hi Elena,

 

I think, you can use the following script, if it works for you:

function check_listbox() {
var the_listbox = document.getElementById("EditRecordFIELDNAME");
var max_number = 3;
var checked = 0;
for (var i=0 ; i < the_listbox.options.length; i++ ) 
 {
   if (the_listbox.options[i].selected) {checked++;}
   if (checked > max_number)
   {
      alert("The maximum of choices is 3!");
      return false;
    }
  }
}
document.getElementById("caspioform").onsubmit = check_listbox;

Please, enter the name of your field instead of FIELDNAME; enter your maximum number and your message.

 

The script will not allow to save the record, if a user selects too many items.

 

I hope, it helps.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...