Copy link to clipboard
Copied
I have a web page that is showing 'Special Offers' that consist of id, title, intro, body_text and state, this information is retrieved from a mysql database.
The state indicates if the 'Special Offer' is active (the user can view it) or inactive (not visable to the user). When the state is inserted into the database active is '1' and inactive '0'.
I'm trying to create an administration page so an administrator can change/update the state of the 'Special offer' by ticking or un-ticking the state checkbox. So far my update page shows the checkbox in the correct state but how do I send a new variable to the database when submitted if the checkbox is changed.
I'm not sure if that explains my problem clear enough, please email me if its not clear.
Copy link to clipboard
Copied
I'm not exactly sure what you are asking, but let me take a guess:
If you are asking about how you handle updating your form's action page when you submit your form that contains your checkbox:
1) use <cfparam> on your action page to set a default value to your checkbox form variable
e.g. <cfparam name="FORM.myCheckBoxField" default="0">
2) In your Update statement, use the value of yor check box field variable as the value you are setting your DB field to:
e.g. UPDATE myTable
SET title = <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#FORM.myTitleField#">,
accessible = <cfqueryparam cfsqltype="CF_SQL_BIT" value="#FORM.myCheckBoxField#">
WHERE myTableID = <cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#Form.myRecordID#">
or
UPDATE myTable
SET title = <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#FORM.myTitleField#">,
<cfif FORM.myCheckBoxField eq 0>
accessible = 0,
<cfelse>
accessible = 1,
</cfif>
WHERE myTableID = <cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#Form.myRecordID#">
Hope that helps,
- Michael
Copy link to clipboard
Copied
On your form page, put a hidden field, name=state, value=0 before your checkbox.
On your processing page, process listlast(form.state)
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more