koila
asked on
I have an update statement in coldfusion.
I have a 6 criteria A, B, C, D, E or F
<cfif CMTEE_PREF_NEW EQ "A" or "B" or "C" or "D" or "E" or "F">
CMTEE_PREF_NEW = <cfqueryparam value = "#form.CMTEE_PREF_NEW#" cfsqltype="cf_sql_char" />,
<cfelse>
CMTEE_PREF_NEW = <cfqueryparam value = " " cfsqltype="cf_sql_char" />,
</cfif>
How i'm able to have to correct this
<cfif CMTEE_PREF_NEW EQ "A" or "B" or "C" or "D" or "E" or "F">
<cfif CMTEE_PREF_NEW EQ "A" or "B" or "C" or "D" or "E" or "F">
CMTEE_PREF_NEW = <cfqueryparam value = "#form.CMTEE_PREF_NEW#" cfsqltype="cf_sql_char" />,
<cfelse>
CMTEE_PREF_NEW = <cfqueryparam value = " " cfsqltype="cf_sql_char" />,
</cfif>
How i'm able to have to correct this
<cfif CMTEE_PREF_NEW EQ "A" or "B" or "C" or "D" or "E" or "F">
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
an Update: even if it is not coming from form you can do it like this
<cfset form.CMTEE_PREF_NEW = CMTEE_PREF_NEW> [Here you put this into form Scope]
<cfif listFindNoCase("A,B,C,D,E, F", FORM.CMTEE_PREF_NEW)>
<!--- found --->
<cfelse>
<--- not found --->
</cfif>
or like this
[This may take more time as it will search all scopes, but will not make big difference as list is quite small]
<cfif listFindNoCase("A,B,C,D,E, F", CMTEE_PREF_NEW)>
<!--- found --->
<cfelse>
<--- not found --->
</cfif>
<cfset form.CMTEE_PREF_NEW = CMTEE_PREF_NEW> [Here you put this into form Scope]
<cfif listFindNoCase("A,B,C,D,E,
<!--- found --->
<cfelse>
<--- not found --->
</cfif>
or like this
[This may take more time as it will search all scopes, but will not make big difference as list is quite small]
<cfif listFindNoCase("A,B,C,D,E,
<!--- found --->
<cfelse>
<--- not found --->
</cfif>
ASKER
Hi Agax,
thank you. If I don't check any box of question 2, i'm having this error. How i'm able to resolved please help me. thank you!
Element CMTEE_PREF_NEW is undefined in FORM. <br>The error occurred on line 52.
on line 52 I have this code line.
<cfif listFindNoCase("POL,SOP,EE ,ADMIN,TF, ANY", FORM.CMTEE_PREF_NEW)>
This is the front end of question 2:
-========================= ===
thank you. If I don't check any box of question 2, i'm having this error. How i'm able to resolved please help me. thank you!
Element CMTEE_PREF_NEW is undefined in FORM. <br>The error occurred on line 52.
on line 52 I have this code line.
<cfif listFindNoCase("POL,SOP,EE
This is the front end of question 2:
-=========================
<table border="0" cellspacing="0" cellpadding="0" width="100%" class="qtable">
<tr>
<td colspan="2" height="5" width="100%">
<input type="checkbox" name="CMTEE_PREF_NEW" id="CMTEE_PREF1" value="POL"
<cfif listFindNoCase(DisplayCVITool.CMTEE_PREF, "POL")>checked</cfif>>
<label>Policy setting committees (POL)</label>
<br>
<input type="checkbox" name="CMTEE_PREF_NEW" id="CMTEE_PREF2"
value="SOP"
<cfif listFindNoCase(DisplayCVITool.CMTEE_PREF, "SOP")>checked</cfif>>
<label>Standard of practice setting committees (SOP)</label>
<br>
<input type="checkbox" name="CMTEE_PREF_NEW" id="CMTEE_PREF3"
value="EE"
<cfif listFindNoCase(DisplayCVITool.CMTEE_PREF, "EE")>checked</cfif>>
<label>
Committees related to education and eligibility issues <em>(EE)</em></
label><br>
<input type="checkbox" name="CMTEE_PREF_NEW" id="CMTEE_PREF4"
value="ADMIN"
<cfif listFindNoCase(DisplayCVITool.CMTEE_PREF, "ADMIN")>checked</cfif>>
<label>Administrative committees such as Finance or Elections <em>(ADMIN)</em></label>
<br>
<input type="checkbox" name="CMTEE_PREF_NEW" id="CMTEE_PREF5"
value="TF"
<cfif listFindNoCase(DisplayCVITool.CMTEE_PREF, "TF")>checked</cfif>>
<label>Task Forces (typically short term commitment) <em>(TF)</em></label>
<br>
<input type="checkbox" name="CMTEE_PREF_NEW" id="CMTEE_PREF6"
value="ANY"
<cfif listFindNoCase(DisplayCVITool.CMTEE_PREF, "ANY")>checked</cfif>>
<label>Doesn’t matter, I just want to volunteer. <em>(ANY)</em></label>
<br>
<input type="checkbox" name="CMTEE_PREF_NEW" id="CMTEE_PREF7"
value="SP"
<cfif listFindNoCase(DisplayCVITool.CMTEE_PREF, "ANY")>checked</cfif>>
<label>Specialist Volunteer Groups (such as the Actuarial Foundation of Canada) <em>(SP)</em></label></td>
</tr>
</table>
confirmation-e.txt
@koila - Checkbox fields will only exist if something was checked. There's 2 ways to handle it:
- Use cfparam at the top of the page to assign a default value. That'll ensure the field always exists ie
<cfparam name="FORM.CMTEE_PREF_NEW" default="">
- The other is to verify it exists *before* using it in an expression, ie Use
<cfif structKeyExists(FORM, "CMTEE_PREF_NEW") AND
listFindNoCase("POL,SOP,EE ,ADMIN,TF, ANY", FORM.CMTEE_PREF_NEW)>
CMTEE_PREF_NEW = <cfqueryparam value = "#form.CMTEE_PREF_NEW#"
cfsqltype="cf_sql_char" />,
<cfelse>
CMTEE_PREF_NEW = <cfqueryparam value = " " cfsqltype="cf_sql_char" />,
</cfif>
- Use cfparam at the top of the page to assign a default value. That'll ensure the field always exists ie
<cfparam name="FORM.CMTEE_PREF_NEW"
- The other is to verify it exists *before* using it in an expression, ie Use
<cfif structKeyExists(FORM, "CMTEE_PREF_NEW") AND
listFindNoCase("POL,SOP,EE
CMTEE_PREF_NEW = <cfqueryparam value = "#form.CMTEE_PREF_NEW#"
cfsqltype="cf_sql_char" />,
<cfelse>
CMTEE_PREF_NEW = <cfqueryparam value = " " cfsqltype="cf_sql_char" />,
</cfif>
ASKER
I will test. You are the best expert. Pls review my others questions pls pls
I'll check it out as soon as I'm done w/my meetings.
Open in new window
Otherwise, you'd have to write your OR expression this way:<cfif CMTEE_PREF_NEW EQ "A" or CMTEE_PREF_NEW EQ "B" or CMTEE_PREF_NEW EQ "C" or CMTEE_PREF_NEW EQ "D" or CMTEE_PREF_NEW EQ "E" or CMTEE_PREF_NEW EQ "F">