Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drop down menu date

Status
Not open for further replies.

dip

Programmer
Aug 15, 2000
20
SG
Hai,

I have created a drop down menu date which takes the system date. The problem is that i am not very sure of how i am going to put the date into the database. I have two other fields that is pm_name and project_name. This two fields i am able to get the information into the database but i am not able to do so for the date. How am i going to insert it into the database?

This is the code:-

<cfif isdefined(&quot;form.submit1&quot;)>

<cfquery datasource=&quot;Producer&quot;>
INSERT into Project_Manager
(pm_name,project_name)VALUES
('#form.pm_name#','#form.project_name#')
</cfquery>

<cflocation url=&quot;menu_index.cfm&quot; addtoken=&quot;No&quot;>
<cfelse>

<cfparam name=&quot;year&quot; default=&quot;#year(now())#&quot;>
<cfparam name=&quot;month&quot; default=&quot;#month(now())#&quot;>
<cfparam name=&quot;day&quot; default=&quot;#day(now())#&quot;>
<cfset lastday=DaysInMonth(CreateDate(year,month,1))>
<cfif day GTE lastday><cfset day=lastday></cfif>
<cfset thedate=CreateDate(year,month,day)>
<cfif month EQ 12>
<cfset nextmonth=1><cfset nextyear=year+1>
<cfelse>
<cfset nextmonth=month+1><cfset nextyear=year>
</cfif>
<cfif month EQ 1>
<cfset prevmonth=12><cfset prevyear=year-1>
<cfelse>
<cfset prevmonth=month-1><cfset prevyear=year>
</cfif>
<cfset nextCalMonth=&quot;day=#day#&month=#nextmonth#&year=#nextyear#&quot;>
<cfset prevCalMonth=&quot;day=#day#&month=#prevmonth#&year=#prevyear#&quot;>
<cfset b_date_day=day>
<cfset b_date_month=month>
<cfset b_date_year=year>

------------------------------------------------------------
This is the part where the drop down menu date is
------------------------------------------------------------

<tr>
<td nowrap>
<div align=&quot;right&quot;> <font face=&quot;Arial, Helvetica, sans-serif&quot; size=&quot;2&quot;>
<B>Date :</b></font></div>
</td>
<td>
<cf_z_date day=#day# month=#month# year=#year# year_before=#val(year-Year(now()))# year_after=5>
</td>
<tr>

<CF_Z_DATE> is a ColdFusion tags that creates drop down list of days, months & years. The default selected date will be the the current date. There are only options of changing the (variable) name for the drop down list. The default are 'day', 'month' and 'year'.

dip.
 
You can do it using many ways, here's one method:

<form...>
<select name=&quot;month&quot;>
<cfloop index=&quot;m&quot; from=1 to=12>
<option value=&quot;#m#&quot;>#monthasstring(m)#
</cfloop>
</select>
<select name=&quot;day&quot;>
...
</form>

Then once posted:

<cfset TheDate = #month# & &quot;/&quot; & #day# & &quot;/&quot; & &quot;#year#&quot;>
OR
<cfset TheDate = CreateDate(#month#, #day#, #year#)>

<cfif isDate(TheDate)>
<cfquery ...>
insert into Table
(
Date,
...
)
values
(
'#TheDate#'
)
</cfquery>
</cfif>

Again, it's one method out of many. I suspect that the information on how to deal with it once posted will help. [sig]<p> <br><a href=mailto:aberman@thebiz.net>aberman@thebiz.net</a><br><a href= > </a><br>Database web programmer and developer, fueled by peach snapple and mochas.[/sig]
 
If what you are trying to do is place into the db the date a form was submitted, why not set up a date/time field with the default value as &quot;Now()&quot; and leave it out of the form. Each time the form creates a record, it will place the server date/time in that field and leave the person submitting out of it. You can get the value out later using a variety of CF dateformat methods to make it pretty.

If that isn't what you are trying to do... have you tried raspberry snapple?

MO
 
Are you trying to do a dropdown list for a date like a credit card expiration date? In what context is this being used? Kevin
slanek@ssd.fsi.com
 
iqof188,

Couldn't find it on the site. Any idea what category of custom tags it fits in (I looked through development assistance and searched)?

Thanks.

Profwannabe
 
I couldn't find it on allaire's site either. Did you find it there, iqof188 or are you just assuming? Kevin
slanek@ssd.fsi.com
 
Yeah, I'm just assuming. Where have you heard about the <CF_Z_DATE> tag? Aren't there any other tags that do the same but have different names? It seems like they have a tag for practically anything you can and want to do with a date :)
There's some other sites too with custom tags:


This is just a selection of sites that offer custom tags. Hope you guys find it...

<webguru>iqof188</webguru>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top