You could do a second update as follows:

Update survey Set hot = 0 Where SID not in (10,17)

A warning though: A "not in" query only runs well on
well-indexed or small tables. If your table doesn't meet
those standards then you'd be better off getting the whole
list of SIDs as a list and removing the ones that were checked
then running the "in" statement with the remainder.

Margaret

-----Original Message-----
From: Tony Carcieri [mailto:[EMAIL PROTECTED]]
Sent: Monday, October 07, 2002 10:39 AM
To: CF-Talk
Subject: I lost my brain - checkboxes


Hi all,

Sorry for the stupid post today but I cannot think.

I have an input field on a form:
<input type="checkbox" name="hotlead" value="<cfoutput>#SID#</cfoutput>">
(SID is the primary key in the SQL 2K DB).

then on the page:
<cfloop query="GetInfo">
    <tr>
        <td><input type="checkbox" name="hotlead"
value="<cfoutput>#SID#</cfoutput>" <cfif Hot EQ 1>checked</cfif></td>
    </tr>
</cfloop>

So here is my problem. When a checkbox (or more) is checked, I do this SQL
statement:
UPDATE survey SET Hot = 1 WHERE SID IN (10,17) and this works great.
However, if I deselect the checkbox I no longer have the SID:
UPDATE survey SET Hot = 1 WHERE SID IN 0 (makes sense the value is the SID).

So how do I do this?
I want to set the Hot field to 1 on only the SID when checked and if i
deselect it, then i want the field to be set to 0 on the SID i deselect. The
default value in the Hot (bit) field is 0.

Thanks,
Tony


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

Reply via email to