Reputation: 1456
I am creating a single page application. I am trying to select a table in sql and search a field for a certain date Date_Due
then to make sure another field Date_Complete
is null. I am trying to figure out how to have a hidden field fill in a cfparam in my query. My hidden field automatically has the correct date done because of JQuery but I need to know how to pass the form.value to the param since nothing is being submitted or inserted. Its just a hidden field with the correct date already that I need to some how automatically pass to the query inside of the param.
http://jsfiddle.net/byyeh83t/8/
The fiddle shows the input automatically receiving the date. But since nothing is being submitted no button press nothing how do I take the form.value and insert that into the param in my query?
<input name="TomorrowsDate" id="TomorrowsDate" type="hidden"/>
<cfquery name="tomorrowTextArea">
SELECT *
FROM dbo.Dealer_Track_Work
WHERE Date_Due = <cfqueryparam value="form.TomorrowsDate" />
AND Date_Complete IS NULL
</cfquery>
Upvotes: 2
Views: 118
Reputation: 400
The timeline for your webpage looks this way:
If you don't want to reload your page
But since nothing is being submitted no button press nothing
some kind of an asynchronous message is required.
var dateForQuery = AddBusinessDays(dateMin, 1);
$.ajax(
'your_query_page.cfm',
{data: {date: dateForQuery }}
).done(function(result){
\\ do something with the query result
});
And on the server side:
<cfparam name="URL.date" default="#Now()#" />
<cfquery name="tomorrowTextArea">
SELECT *
FROM dbo.Dealer_Track_Work
WHERE Date_Due = <cfqueryparam value="#URL.date#" />
AND Date_Complete IS NULL
</cfquery>
<cfoutput>#SerializeJSON(tomorrowTextArea)#</cfoutput>
Upvotes: 2