House of Fusion
Home of the ColdFusion Community

Search cf-talk

December 02, 2008

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
   1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31       

Search over 2,500 ColdFusion resources here  >>>      
Home /  Groups /  ColdFusion Talk (CF-Talk)

Setting a default value

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Les Mizzell
09/05/2008 11:29 AM

In the scenerio below, how would I set a default value - "99" maybe - for form.group_sort_#gpIDX# - if the form field was left blank? <cfloop index="idx" list="#FORM.GROUPid#"> <cfquery name="update">    UPDATE MyTable    SET       group_sort = #evaluate("form.group_sort_#gpIDX#")#       where link_group = '#evaluate("form.thisGROUP_#gpIDX#")#' </cfquery> </cfloop>

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Brad Wood
09/05/2008 11:35 AM

> In the scenerio below, how would I set a default value - "99" maybe - > for form.group_sort_#gpIDX# - if the form field was left blank? I'm sure there are many ways, but this should work.  Also, don't forget to secure those queries against SQL Injection  ;-> <cfloop index="idx" list="#FORM.GROUPid#"> <cfset this_group_sort = form["group_sort_#gpIDX#"]> <cfquery name="update">   UPDATE MyTable   SET      group_sort = #iif(len(trim(this_group_sort)),"this_group_sort",99)#      where link_group = '#evaluate("form.thisGROUP_#gpIDX#")#' </cfquery> </cfloop> ~Brad

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Aaron Rouse
09/05/2008 11:36 AM

You could do this, it assumes the form element would always be passed but might be blank.  If the form element may not get passed then you could do a cfparam but that would not handle if it passed and blank.  Also I assumed #gpIDX# was really supposed to be #idx# <cfloop index="idx" list="#FORM.GROUPid#"> <cfif Trim(Form["group_sort_#idx#"]) IS ""> <cfset Form["group_sort_#idx#"] = 99 /> </cfif> <cfquery name="update">   UPDATE MyTable   SET group_sort = #Form["group_sort_#idx#"]# where link_group = 'Form["thisGROUP_#idx#"]' </cfquery> </cfloop> ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Aaron Rouse
09/05/2008 11:37 AM

Erf, I left off some pound signs on the where clause where link_group = '#Form["thisGROUP_#idx#"]#' On Fri, Sep 5, 2008 at 10:32 AM, Aar ----- Excess quoted text cut - see Original Post for more -----


<< Previous Thread Today's Threads Next Thread >>

Mailing Lists