By: Rhino

<---This will allow you to use checkboxes in your update files when changing information--->

<CFQUERY
    name=
"[queryname]"
    datasource=
"[dsn]">
Select * from [tablename]
where id = #url.id#
</cfquery>

<---Insert an HTML form here to make updates --->


<---Where checkboxes are needed add this code --->


<CFIF smokingok IS "yes">
    <INPUT TYPE="Checkbox" NAME="smokingok" checked>
<CFELSE>
    <INPUT TYPE="Checkbox" NAME="smokingok">
</CFIF>


<---The important thing is to have a CFPARAM line in the file that processes this form --->
<---If the value is YES in the DB and the checkbox is unchecked, it won't send anything and it will still be YES in the DB --->
<--- Put this before anything else, if there are several then just list them all --->


<CFIF IsDefined("smokingok") is "YES">
    <CFSET smokingok = "yes">
<CFELSE>
    <CFSET smokingok =
"">
</CFIF>

About This Tutorial
Author: Rhino
Skill Level: Beginner 
 
 
 
Platforms Tested: CF5
Total Views: 35,643
Submission Date: March 31, 2004
Last Update Date: June 05, 2009
All Tutorials By This Autor: 10
Discuss This Tutorial
  • why not just use: checked /> saves on coding and works well.

  • None of you can come close to the lightning fast chops I possess. If you can't understand my code, it's because you can't cut it. You ain't got da chops dog boy. Stuffed up like a zebra in heat? WANKERS. My code is tight and smooth. It's bullet proof. I am the Cold Fusion Shazaam. WHAM BAM Thank You Mam. You all got spanked and you just can't take it. I said it before and I will say it again, this is just a bad tutorial. Not because its badly worded or anything, just that it is bad programming. This Hippo or Rhino character needs to get checked out by the Doctor of Code, and I say prognosis NEGATIVE. Booya scratch tiger. You get kicked out. CHUMP!!!!

  • Here's the way Macromedia suggest, and it works: Yes
    Yes
    You also don't need this: For more info: http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/update11.htm

  • If your confused about what code to use. Use Rhino's, because WANKER Maz's code (the way he explains it), does not work.

  • OK I'm not going to slam anyone's code or skill level. I steal from the best and the worst. I still don't quit get how to implement this code, though I believe it is addressing the exact issue I am experiencing. If I have a web form created in FP with check boxes and radio buttons, where do I put the check and how does it know the CB/Radio is “yes” or "1"? I’ve been using CF for 2 days now and have succeeded in creating a very basic cfmail script but need to be able make it more useful. THis site is just what I've been looking for. JH-notsoproudcodethief

  • You see if you do it the way he has it listed, it will take .00003 seconds to calculate, but my way will save .0000001. I am by far a better programmer than this terd.

  • ..thats just a bad tutorial. Not because its badly worded or anything, just that it is bad programming. This is more efficient checked> Plus its not a problem anyway if you add the value="" attribute so you can set what the ticked value is. I use value="1" for ticked, if unticked its blank or null so then i just query the code safely always using noyes

  • This code will display the appropriate "check" or "unchecked" box from existing records from the recordset, but there is no code to actually update it. I guess it's a 5 for accuracy, but as the comments show, beginners were looking for the whole code, not just a patchjob.

  • Perhaps it's so far above your skills you can't comprehend what it does, and you therefore rate it a one? I don't know what it does either, but I have the smarts enough not to trash the tutorial, because I don't know what it does.

  • I have no idea how to implement this? Give me more code. Make up some queries and such, if I copy and paste this alone it isn't going to work, a tutorial should basically work when you copy and past. Also including descriptions (detailed) of what was done. I was trying to update a yes/no data type in a database with a check box on my web page, I thought this might be the solution...????

Advertisement

Sponsored By...
Powered By...