From: GArlington on
On Apr 22, 4:24 am, "susanring" <webforumsu...(a)macromedia.com> wrote:
> Hello,
> I have this drop down fruits and
> it can be in any state but what I want is that if it cahnges from one value to
> another a specific email is sent.
>
> if the value is DD to any letter A,B,C,D,E,F
>
> a EMAIL MESSAGE IS SENT
> from="Y...(a)gmail.com"
> to="B...(a)gmail.com"
>
> MESSAGE WILL BE
> depending on what they choose
> drop down
> DD to A
> message will be
> YOU HAVE CHANGED dd TO a.
>
> if
> DD to B
> message will be
> YOU HAVE CHANGED dd TO B.
>
> and so on
>
> here is my code.
>
> at this point there are no errors when it is submited but also no errors.
>
> DISPLAY PAGE
>
> <br>
> <br>
> <div align="center" class="prompt">
> Please enter Fruit INFO:<br>
> <br>
> </div>
>
> <cfoutput>
> <cfform name="Fruit" method="post" action="#variables.self#">
> <input type="hidden" name="fuseaction" value="#XFA.submit#">
>
> <table border="0" cellpadding="2" cellspacing="2" align="center">
> <tr>
> <td align="right">* Fruit Status:</td>
> <td>
> <input type="hidden" name="prv_Fruit_status"
> value="#formVal.Fruit_Status#" />
> <select name="Fruit_Status">
> <cfloop query="qFruitStatus">
> <cfif (qFruitStatus.Fruit_Status NEQ "C")
> OR (qFruitStatus.Fruit_Status EQ "C"
> AND (Left(formVal.Fruit_Status, 9) EQ "A"
> OR formVal.Fruit_Status EQ "C"
> )
> )
> >

From the code above I suspect that you are do NOT quite understand
that your above code runs on CF (server) and the changes (by the user)
are done on the client (browser) AFTER CF is done...
So, in fact you do not need any of your <cfif ...> here, just do
<cfoutput query="qFruitStatus"><option ...></option></cfoutput>
> <option value="#qFruitStatus.Fruit_Status#" <cfif
> qFruitStatus.Fruit_Status EQ
> formVal.Fruit_Status>selected</cfif>>#qFruitStatus.Fruit_Status#</option>
> </cfif>
> </cfloop>
> </select>
> </td>
> </tr>
>
> <td colspan="2" align="center">
> <input type="Reset" value="Reset">&nbsp;
> <input type="submit" value="Submit">
> </td>
> </tr>
> </table>
> </cfform>
> </cfoutput>
> <br>
>

Now, once the user changed some values (in your select) they submit
the form at it goes to your action page bellow, it NEVER goes back to
your form page...

> ------------------------------------------------------
>
> ACTION PAGE
>
> <cfparam name="attributes.Fruit_Status" default="">
>
> <cfquery name="updateFruit" datasource="#request.site.QTSDSN#">
> UPDATE tbl_Fruit
> SET
> Fruit_Status = <cfqueryparam value="#Trim(attributes.Fruit_Status)#"
> cfsqltype="CF_SQL_VARCHAR">
>
> WHERE ID = <cfqueryparam value="#attributes.ID#" cfsqltype="CF_SQL_INTEGER">
> </cfquery>
>
> <cfif attributes.prv_Fruit_status eq "DD">
> <cfswitch expression="#attributes.Fruit_Status#">
> <cfcase value="A|D|C|B and E|F" delimiters="|">
> <!--- Send Email Notice --->
> <cfmail
> from="Y...(a)gmail.com"
> to="B...(a)gmail.com"
> subject="Test"
> >
> This is a test.

Just try:
Fruit_Status for <cfoutput>#attributes.ID# changed to
#attributes.Fruit_Status#</cfoutput>

> ---------------------------------------------------
> </cfmail>
> </cfcase>
> </cfswitch>
> </cfif>