• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Creating drop down

Guest
Dec 01, 2006 Dec 01, 2006

Copy link to clipboard

Copied

I am looking to create a dropdown that allows you to select a day of the month and when you click on the date take you to the query that will report the results for that particular day.
Any help gratefully received.
TOPICS
Advanced techniques

Views

573

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 01, 2006 Dec 01, 2006

Copy link to clipboard

Copied

Does the user also select a month? If not, do they always get the current month?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 01, 2006 Dec 01, 2006

Copy link to clipboard

Copied

Dan, yes they will also have to select a month.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 01, 2006 Dec 01, 2006

Copy link to clipboard

Copied

You can generate simple select boxes this way:

<SELECT NAME="month">
<CFLOOP INDEX="mo" FROM="1" TO="12"><OPTION VALUE="#mo#">#MonthAsString(mo)#</CFLOOP>
</SELECT>
<SELECT NAME="day">
<CFLOOP INDEX="dd" FROM="1" TO="31"><OPTION VALUE="#dd#">#dd#</CFLOOP>
</SELECT>

When you pass the value to your query, you can use CreateDate with the values for month and day (and year). You can add some validation since some months don't have 31 days.

Another way to do this is to display a visual calendar and have each date be a link to your query page, passing the date info as a URL parameter. See attached code.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 01, 2006 Dec 01, 2006

Copy link to clipboard

Copied

My suggestion is to forget about drop downs. Either go with a text box or a javascript/flash calendar.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 01, 2006 Dec 01, 2006

Copy link to clipboard

Copied

Dan - just out of curiousity...why a textbox? I like the idea of the JS/Flash calendar (when there are no restrictions on using JS or Flash)...but if you're using plain' ol' HTML form elements, wouldn't a series of drop downs be better? A text input would require extra validation and parsing whereas dropdowns would require minimal validation and no string parsing.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 01, 2006 Dec 01, 2006

Copy link to clipboard

Copied

Selects would be horrible. If you don't believe me, code yourself a form and then write the necessary client side validation to ensure that you don't submit an invalid date, like 2006-02-29.

One of my pet peeves is that all applications should be equally useable to keyboard pounders as they are to mouse pullers. That's my knock against the cfcalendar tag, you can't tab into it if you have an html form.

Regarding js calendars, there are lot's of them out there. They all work slightly differently.

Text boxes are simple. Here is how I usually code them. Bear in mind that do intranet, not internet programming, Among other things, I don't have to worry about users disabling their javascript.

<cfinput type="text" size="10" maxlength="10" value="#session.injurydate#"
message="Injury Date Must Be a Date" mask="9999-99-99"
name="injurydate" validate="date" validateat="onsubmit">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 01, 2006 Dec 01, 2006

Copy link to clipboard

Copied

I've attached a nice little piece of code that I use EVERYWHERE... gets around your date validation functions, knows the difference between leap years etc.

Notice it submits the form on change? To get around having someone change the date and accidentally submit the form for processing I usually
<cfif (IsDefined("form.submit")) and (action is "submit for processing")>
>> process the form!
</cfif>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 01, 2006 Dec 01, 2006

Copy link to clipboard

Copied

LATEST
@dan - fair enough. for what it's worth, i've written the JS validation to handle the drop-downs (ensuring feb 30th can't be selected for example). i still find that easier to deal with than parsing a string (also bear in mind i'm not a big fan of cfform so i don't use cfinput). agreed on the usability aspect tho. would be nicer to keep things consistent for the keyboard pounders :)

@sean - with all due respect, the thought of having the form submit potentially multiple times in order to capture a single date value doesn't sit well with me at all. i'd rather code the client side validation to manipulate the "dobday" drop down based on the value of 'month' and/or 'year' or go an AJAX route. just my $0.02 (for whatever it's worth) 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation