• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Related to drop down selecting multiple values

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I wanted to have a drop down in which multiple values can be selected at a time but at the same time i want to set that how many values can be selected (for eg: user can set whether 3 values can be selected or 5 values can be selected at a time).

Please help,

Aashu.
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can validate the number of selection on serverside
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing to do with JSP, so moved to a more appropriate forum.
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ashutosh Arya wrote:Hi,

I wanted to have a drop down in which multiple values can be selected at a time but at the same time i want to set that how many values can be selected (for eg: user can set whether 3 values can be selected or 5 values can be selected at a time).

Please help,

Aashu.




Hi Aashu...

This is possible using javascript as well...
iterate through the list, and check each element, if its selected...
set a counter to check the no. of elements selected...

Please find the code below implemented with a <h:selectManyListbox id="teamList">

var teamCount = (document.getElementById('formName:teamList')).length;
var count=0;
for (var i = 0; i < teamCount; i = i + 1) {
var tempChar = (document.getElementById('formName:teamList')).options[i];
if(tempChar.selected){
count=count+1;
}
if(count>1)
break;
}

if(count>1){
alert("Only single team can be selected");
}

The above code allows only one team to be selected.
But in case you have a huge list with thousand of records, this could take some time...


All the Best
Mansi
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic