I am trying to insert a date into a database from a date
chooser using Javascript. My form page is as follows:
%26lt;!DOCTYPE html PUBLIC ''-//W3C//DTD XHTML 1.0
Transitional//EN'' ''
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd''%26gt;
%26lt;html xmlns=''
http://www.w3.org/1999/xhtml''%26gt;
%26lt;head%26gt;
%26lt;script language=''javascript'' type=''text/javascript''
src=''datetimepicker.js''%26gt;
//Date Time Picker script- by TengYong Ng of
http://www.rainforestnet.com
//Script featured on JavaScript Kit (
http://www.javascriptkit.com)
//For this script, visit
http://www.javascriptkit.com
%26lt;/script%26gt;
%26lt;meta http-equiv=''Content-Type'' content=''text/html;
charset=iso-8859-1'' /%26gt;
%26lt;title%26gt;Form%26lt;/title%26gt;
%26lt;style type=''text/css''%26gt;
.content {
border:1px #000000 solid;
}
body {background:white;
}
%26lt;/style%26gt;
%26lt;/head%26gt;
%26lt;body%26gt;
%26lt;div id=''content''%26gt;
%26lt;form action=''insert.cfm'' method=''post''%26gt;
%26lt;table align=''left'' bgcolor=''white''%26gt;
%26lt;tr%26gt;
%26lt;th colspan=''2''%26gt;
%26lt;font size=''+1''%26gt;Add an Event%26lt;/font%26gt;
%26lt;/th%26gt;
%26lt;/tr%26gt;
%26lt;tr%26gt;
%26lt;td%26gt;
Title:
%26lt;/td%26gt;
%26lt;td%26gt;
%26lt;input type=''text'' name=''title'' size=''50'' maxlength=''40''
/%26gt;
%26lt;/td%26gt;
%26lt;/tr%26gt;
%26lt;tr%26gt;
%26lt;td%26gt;
Date:
%26lt;/td%26gt;
%26lt;td%26gt;
%26lt;input id=''demo1'' type=''text'' size=''25''
name=''demo1''%26gt;%26lt;a
href=''javascript:NewCal('demo1','ddmmyyyy')''%26gt;%26lt;img
src=''cal.gif'' width=''16'' height=''16'' border=''0'' alt=''Pick a
date''%26gt;%26lt;/a%26gt;
%26lt;/td%26gt;
%26lt;/tr%26gt;
%26lt;tr%26gt;
%26lt;td%26gt;
Description:
%26lt;/td%26gt;
%26lt;td%26gt;
%26lt;textarea name=''Description'' cols=''40'' rows=''5''
wrap=''virtual''%26gt;%26lt;/textarea%26gt;
%26lt;/td%26gt;
%26lt;/tr%26gt;
%26lt;td%26gt;
%26lt;input type=''submit'' value=''Insert'' align=''right'' /%26gt;
%26lt;/td%26gt;
%26lt;/tr%26gt;
%26lt;/div%26gt;
%26lt;/body%26gt;
%26lt;/html%26gt;
and my insert page is:
%26lt;cfquery datasource = ''test''%26gt;
INSERT INTO test(description, event_date, title)
VALUES('#FORM.Description#',
'#FORM.demo1#',
'#FORM.title#'
)
%26lt;/cfquery%26gt;
How can I insert the date into the database? And, How can I
also retrieve that same date from the database. Just for
understaing, I am working on a Web-Calendar for my company.
Thank you for your quick response to this?
Coldfusion mx 7 and MYSQL
Try this to insert it:
%26lt;cfquery datasource = ''test''%26gt;
INSERT INTO test
(description, event_date, title)
VALUES
(
'#FORM.Description#',
%26lt;cfqueryparam cfsqltype=''cf_sql_date''
value=''#FORM.demo1#''%26gt;,
'#FORM.title#'
)
%26lt;/cfquery%26gt;
And to display it on a page, assuming the recordset name was
rsName:
%26lt;cfoutput%26gt;#DateFormat(rsName.event_date, ''mmmm dd,
yyyy'')#%26lt;/cfoutput%26gt;
--
Ken Ford
Adobe Community Expert
Fordwebs, LLC
http://www.fordwebs.com
''cliffy2009'' %26lt;webforumsuser@macromedia.com%26gt; wrote in
message news:es773b$sj0$1@forums.macromedia.com...
%26gt; Hi everyone,
%26gt; I am trying to insert a date into a database from a date
chooser using
%26gt; Javascript. My form page is as follows:
%26gt; %26lt;!DOCTYPE html PUBLIC ''-//W3C//DTD XHTML 1.0
Transitional//EN''
%26gt; ''
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd''%26gt;
%26gt; %26lt;html xmlns=''
http://www.w3.org/1999/xhtml''%26gt;
%26gt; %26lt;head%26gt;
%26gt;
%26gt;
%26gt; %26lt;script language=''javascript'' type=''text/javascript''
src=''datetimepicker.js''%26gt;
%26gt;
%26gt; //Date Time Picker script- by TengYong Ng of
http://www.rainforestnet.com
%26gt; //Script featured on JavaScript Kit (
http://www.javascriptkit.com)
%26gt; //For this script, visit
http://www.javascriptkit.com
%26gt;
%26gt; %26lt;/script%26gt;
%26gt; %26lt;meta http-equiv=''Content-Type'' content=''text/html;
charset=iso-8859-1'' /%26gt;
%26gt; %26lt;title%26gt;Form%26lt;/title%26gt;
%26gt; %26lt;style type=''text/css''%26gt;
%26gt; .content {
%26gt; border:1px #000000 solid;
%26gt;
%26gt; }
%26gt; body {background:white;
%26gt; }
%26gt; %26lt;/style%26gt;
%26gt; %26lt;/head%26gt;
%26gt;
%26gt; %26lt;body%26gt;
%26gt; %26lt;div id=''content''%26gt;
%26gt; %26lt;form action=''insert.cfm'' method=''post''%26gt;
%26gt; %26lt;table align=''left'' bgcolor=''white''%26gt;
%26gt; %26lt;tr%26gt;
%26gt; %26lt;th colspan=''2''%26gt;
%26gt; %26lt;font size=''+1''%26gt;Add an Event%26lt;/font%26gt;
%26gt; %26lt;/th%26gt;
%26gt; %26lt;/tr%26gt;
%26gt; %26lt;tr%26gt;
%26gt; %26lt;td%26gt;
%26gt; Title:
%26gt; %26lt;/td%26gt;
%26gt; %26lt;td%26gt;
%26gt; %26lt;input type=''text'' name=''title'' size=''50''
maxlength=''40'' /%26gt;
%26gt; %26lt;/td%26gt;
%26gt; %26lt;/tr%26gt;
%26gt;
%26gt; %26lt;tr%26gt;
%26gt; %26lt;td%26gt;
%26gt; Date:
%26gt; %26lt;/td%26gt;
%26gt; %26lt;td%26gt;
%26gt; %26lt;input id=''demo1'' type=''text'' size=''25''
name=''demo1''%26gt;%26lt;a
%26gt; href=''javascript:NewCal('demo1','ddmmyyyy')''%26gt;%26lt;img
src=''cal.gif'' width=''16''
%26gt; height=''16'' border=''0'' alt=''Pick a date''%26gt;%26lt;/a%26gt;
%26gt;
%26gt; %26lt;/td%26gt;
%26gt; %26lt;/tr%26gt;
%26gt;
%26gt; %26lt;tr%26gt;
%26gt; %26lt;td%26gt;
%26gt; Description:
%26gt; %26lt;/td%26gt;
%26gt; %26lt;td%26gt;
%26gt; %26lt;textarea name=''Description'' cols=''40'' rows=''5''
wrap=''virtual''%26gt;%26lt;/textarea%26gt;
%26gt; %26lt;/td%26gt;
%26gt; %26lt;/tr%26gt;
%26gt; %26lt;td%26gt;
%26gt; %26lt;input type=''submit'' value=''Insert'' align=''right''
/%26gt;
%26gt; %26lt;/td%26gt;
%26gt; %26lt;/tr%26gt;
%26gt;
%26gt;
%26gt;
%26gt; %26lt;/div%26gt;
%26gt; %26lt;/body%26gt;
%26gt; %26lt;/html%26gt;
%26gt;
%26gt;
%26gt; and my insert page is:
%26gt;
%26gt;
%26gt; %26lt;cfquery datasource = ''test''%26gt;
%26gt; INSERT INTO test(description, event_date, title)
%26gt; VALUES('#FORM.Description#',
%26gt; '#FORM.demo1#',
%26gt; '#FORM.title#'
%26gt; )
%26gt; %26lt;/cfquery%26gt;
%26gt;
%26gt; How can I insert the date into the database? And, How
can I also retrieve that
%26gt; same date from the database. Just for understaing, I am
working on a
%26gt; Web-Calendar for my company.
%26gt; Thank you for your quick response to this?
%26gt;
%26gt;
No comments:
Post a Comment