Skip to main content
Known Participant
August 15, 2013
Answered

Check form input against a list of data

  • August 15, 2013
  • 1 reply
  • 930 views

Hi all,

I apologize in advance if I don't use the proper terminology here.  What I'm trying to do is rather simple, I think, but it's not something I've done before.  I have a short list of dates in a DB table.  Upon a user inputting a date into a form field and submitting it, I would like CF to check the date the user entered against the list of dates in the table.  I'd like to be able to create a cfif/cfelse statement if the input date matches any one of the table dates. Can someone point me in the right direction?

Thanks!

    This topic has been closed for replies.
    Correct answer p_sim

    Oh, sorry I misunderstood.

    "upon form submission" -- Then in the action page, you create a query against the submitted date.

    WHERE date_column = <cfqueryparam value="#form.submittedDate#" cfsqltype="cf_sql_date">

    The if statement looks like this:

    <!--- if record found --->

    <cfif queryName.recordCount>

         Insert response 1

    <cfelse>

         insert response 2

    </cfif>

    1 reply

    p_sim
    Participating Frequently
    August 15, 2013
    straffenpAuthor
    Known Participant
    August 15, 2013

    Thanks, p.sim.  I'm not sure if what I'm trying to do is that complicated, however the example you provided will be helpful for other projects.

    Basically, upon form submission, I want CF to query my db table of dates and if one of those dates matches the date the user selected from a drop down in the form, CF will insert one of two text responses.  So something like,

    <cfif #form.VisitDate# eq any of the dates in #query.OpenDate#>Insert response 1<cfelse>insert response 2</cfif>

    Maybe I'm missing something or overthinking it...

    Thanks again!

    p_sim
    p_simCorrect answer
    Participating Frequently
    August 15, 2013

    Oh, sorry I misunderstood.

    "upon form submission" -- Then in the action page, you create a query against the submitted date.

    WHERE date_column = <cfqueryparam value="#form.submittedDate#" cfsqltype="cf_sql_date">

    The if statement looks like this:

    <!--- if record found --->

    <cfif queryName.recordCount>

         Insert response 1

    <cfelse>

         insert response 2

    </cfif>