Page 1 of 1

Date - valid form drop-down menu

Posted: Sun Nov 01, 2009 4:54 am
by Jafil21
Hello all,

I'm looking into making an XHTML form that will allow for electronic reservations in a club in my area. What I want to do is constrain the amount of days shown in the "day" drop down menu depending on the value selected in the "month" drop down menu. For example, If the user selects "November" as their preferred month, then "31" should not appear as a valid option in the "day" drop down menu. If I were to pick a different route, then I would just provide 31 days for all months.Then I'd check, with the aid of PHP, if specific months were given (for example, if($_POST["month"] = "February")) and then, if the user supplied a day greater than the 28th (February on non-leap years has 28 days), I'd print a warning message saying that the reservation will take place for the 28th of February, are you sure you want to continue, etc. However, this is not a very professional approach, and I wouldn't want to go down that path.

What would I need to do to achieve this effect? I think I might need Javascript, therefore rendering my posting of this enquiry on this subforum a bad idea. Please forgive me if this is the case.

Thank you.

Re: Date - valid form drop-down menu

Posted: Sun Nov 01, 2009 5:10 am
by ramandhingra
How about u just show a calendar javascript control, this way it will be easier for a user to select a date, instead of selecting 3 combos.. check out this one http://www.softcomplex.com/products/tig ... nload.html , its quite easy to use and there are samples in the zip file.

Re: Date - valid form drop-down menu

Posted: Sun Nov 01, 2009 9:28 am
by Jafil21
Wow, this looks quite interesting, thanks!

So, the way I see it, after usage of this particular calendar, my text input "reservation_date" field (to use a crude example) will contain a string such as "17/11/2009". Is there any way (perhaps in the form of a PHP function) I can break this string into "17", "11", and "2009", so as to not lower my database's normalcy?