[RESOLVED] Modifying a DropDown List
I'm trying to improve a booking application I wrote a little while ago, basically the user can book a 'slot' for a light aircraft, at the moment the drop down list is populated as per the flying school booking slots ie. 09:00-10:00 , 10:00-11:00 etc right through until 21:00.
Currently it's up to the user to select a slot that hasn't been booked by cross checking the current bookings (which are always displayed), basically all the slots remain selectable from the dropdown list.
What I would like to do is modify the dropdown list so when a slot is booked it is also removed from the list to prevent future selection.
The dropdown list is not bound to the database at the moment it's been manually populated with list items. I think I will need to bind it or use the booked data from the database to modify the list in some way but not sure how as the database only contains a field called 'slot' to record the booked slot, maybe I need to add fields for each slot.
Thanks for any advice.
Re: Modifying a DropDown List
Quote:
The dropdown list is not bound to the database at the moment it's been manually populated with list items. I think I will need to bind it or use the booked data from the database to modify the list in some way but not sure how as the database only contains a field called 'slot' to record the booked slot, maybe I need to add fields for each slot.
I think you answered your own question here, and it would be easy to implement.
Say you create a table called TIMESLOTS with 2 columns, SLOT_ID and SLOT_TIME and had rows for your time slots:
SLOT_ID SLOT_TIME
1 8:00-9:00
2 9:00-10:00
: :
: :
On your timeslot listbox, set displayMember="SLOT_TIME" and valueMember="SLOT_ID"
Your listbox datasource will bind to the data coming back from a query something like
"select * from TIMESLOTS where SLOT_ID not in (select SLOT_ID from [table with stored appts] where [date of appt] = [date appt is being made])
This will send back only times that have not been taken.
Once the post is made, set the SLOT_ID in the table with the store appointments to equal the selectedValue of your listbox and you're in like Flynn.
Hope this helps some. I think you had a good idea to begin with.
Re: Modifying a DropDown List
Thanks for your help on this, it was the SQL statement needed to get slots not booked that I was wondering about, this has cleared it up for me.
Re: [RESOLVED] Modifying a DropDown List