|
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Setting a default value
In the scenerio below, how would I set a default value - "99" maybe -Les Mizzell 09/05/08 11:29 A > In the scenerio below, how would I set a default value - "99" maybe -Brad Wood 09/05/08 11:35 A You could do this, it assumes the form element would always be passed butAaron Rouse 09/05/08 11:36 A Erf, I left off some pound signs on the where clauseAaron Rouse 09/05/08 11:37 A 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> > 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 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 ----- 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 -----
|
Mailing Lists
|
Latest Fusion Authority Articles
|
||||||