Saturday, March 24, 2012

Listbox - Maximum elements

Hi All,

I have a HTML listbox control in my form. Endusers can add elements to this listbox dynamically. I want to restrict my enduser to add only 10 elements maximum. If the listbox is full i have to diplay one alert message. Is there any simple way to do this.

ThanksI would assume that you're storing the items for the listbox in a database.

Before you do your db insert (or even on page load) get a count of items in the db that belong to that user. You could then display something like "You have 8/10 items saved" on your page. A variety of ways to handle the event if they have 10/10, from turning visibility off on the submit button to putting the form inside a panel and turning it's visibility off and displaying your error message.

0 comments:

Post a Comment