4 Replies Latest reply on Jun 21, 2009 4:31 PM by CFmonger

    compairing a form submission using cfselect to a db record

    CFmonger

      Hello;

      I am writting a small contact form. I want to use cfselect so it will be populated with all the states.I have it working fine, my problem is, when the email is sent from the form, it sends the ID of the state, not the actual state name.I am trying to write an if statement to compair the form.state to the record id in the DB and then when it sends the email, it sends the actual state name in the matched db record.

       

      this is my code, it is pretty simple and strait forward.

       

      Contact page

      <cfquery name="SESSION.stat" datasource="#APPLICATION.dataSource#" cachedwithin="#CreateTimeSpan(0, 6, 0, 0)#">
      SELECT state, ID
      FROM States
      </cfquery>

       

      <cfform......>

      <cfselect enabled="No" name="state" size="1" class="selectstyle" required="yes" message="Please enter your state!" multiple="no" queryPosition="below">
               <option value="" selected>--Select a State--</option>
               <CFOUTPUT query= "SESSION.stat">
               <option value="#ID#">#state#</option>
               </CFOUTPUT></cfselect>

      </cfform>

       

      Response page:

      <cfquery name="SESSION.stat" datasource="#APPLICATION.dataSource#" cachedwithin="#CreateTimeSpan(0, 6, 0, 0)#">
      SELECT state, ID
      FROM States
      </cfquery>

       

      <cfmail to="me@mywebsite.com

              from="#form.email#"
              subject="web siteRequest"
              server="mail.myhost.com"
              port=25
              type="HTML">
      <font face="Verdana, Arial, Helvetica, sans-serif" color="##000000" size="2">
      <b>Status:</b>           <b>Request!!</b><br>

      <!--- this is my error query --->

      <cfoutput query="stat">
        C  <b>Customer State:</b>   #state#<br>
        </cfif>
        </cfoutput>

      </cfmail>

       

      I think need to fix
        <cfif form.state EQ ('#ID#')>
        <b>Customer State:</b>   #state#<br>
        </cfif>

      this is not working properly, and i forget how to compare the orm submission to the DB record. Can anyone help me out?
      thank you.

       

      CFmonger