Solved

update checkboxes  - can't figure it out!!!

Posted on 2003-12-03
11
159 Views
Last Modified: 2013-12-24
i know this must be staring me right in the face but i can't get it:

a few of the fields i'm trying to update in my db are represented by checkboxes on my form and i can't get them to update properly!!

here's my code:

<cfparam name="form.Exhibition" default="">

Exhibition=
  <cfif IsDefined("FORM.Exhibition")>
    1
    <cfelse>
    0
  </cfif>

<input <cfif (#Artwork.Exhibition# EQ 1)>checked</cfif> name="Exhibition" type="checkbox" id="Exhibition" value="">

thanks!!!
0
Comment
Question by:phillystyle123
11 Comments
 
LVL 17

Accepted Solution

by:
Tacobell777 earned 25 total points
ID: 9871653
<cfparam name="form.Exhibition" default="0">

Exhibition=
  <cfif FORM.Exhibition>
    1
    <cfelse>
    0
  </cfif>

<input name="Exhibition" type="checkbox" id="Exhibition" value="" <cfif form.Exhibition>checked</cfif>>

If you retrieve your records from the db and output them you would have to copy them to the form scope, like so

SELECT here

<cfset form.Exhibition = myQuery.Exhibition>
Etc.
Etc.
0
 

Author Comment

by:phillystyle123
ID: 9871799
i don't get that code - i've been using it all along and all of my checkboxes ended up always generating a value of 1. i ended up doing this:

Exhibition=
  <cfif form.Exhibition eq 1>
  <cfif IsDefined("FORM.Exhibition")>
    1
    <cfelse>
    0
  </cfif>
  <cfelseif form.Exhibition eq 0>
  <cfif IsDefined("FORM.Exhibition")>
    0
    <cfelse>
    1
  </cfif>
  </cfif>

and this

<input <cfif (#Artwork.Exhibition# EQ 1)>checked</cfif> name="Exhibition" type="checkbox" id="Exhibition" value="1">

and this

<cfparam name="form.Exhibition" default="0">
0
 
LVL 12

Assisted Solution

by:jyokum
jyokum earned 25 total points
ID: 9872140
your code's a bit confusing... you're setting up a parameter and checking the existance of form.Exhibition but your actual input checks the value of Artwork.Exhibition.  Doesn't really seem that the 2 are related

I would expect it to look more like:

<cfparam name="form.Exhibition" default="0">
<input name="Exhibition" type="checkbox" id="Exhibition" value="1" <cfif form.Exhibition>checked</cfif>>

OR

<cfparam name="Artwork.Exhibition" default="0">
<input name="Exhibition" type="checkbox" id="Exhibition" value="1" <cfif Artwork.Exhibition>checked</cfif>>
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 17

Expert Comment

by:anandkp
ID: 9872220
is it the display of ur form or ur query that u want us to help u out with ?

can u pls let us know a bit more ...

K'Rgds
Anand
0
 
LVL 11

Expert Comment

by:hart
ID: 9872412
i hope this is what u mean
in ur form page u have

<cfquery name="Artwork" datasource="dsn name">
   blah blah blah...
</cfquery>
<form name="frm" action="actionpage.cfm" method="post">
  Exhibition :
<input name="Exhibition" type="checkbox" value="1" <cfif Artwork.Exhibition eq 1>checked</cfif>>  Yes
<input name="Exhibition" type="checkbox" value="0" <cfif Artwork.Exhibition eq 0>checked</cfif>>  No
</form>


in ur actionpage.cfm.... u do this ---------------------------------------------

<cfparam name="Exhibition" value="0">

<cfquery name="upd_table" datasource="dsn">
  update table set exhibition = <CFQUERYPARAM VALUE="#Exhibition#"
    CFSQLType="CF_SQL_INTEGER">
</cfquery>


Hope this is how u r doing it..

Regards
Hart
0
 

Author Comment

by:phillystyle123
ID: 9873238
basically before i put the
<cfif form.Exhibition eq 1> and
<cfelseif form.Exhibition eq 0>
  infront of
<cfelseif form.Exhibition eq 0>
i was always generating a value of 1 from all of my checkboxes whether i checked them or not.  
 
this code actually now works for me - is there anything wrong with it?

Exhibition=
  <cfif form.Exhibition eq 1>
  <cfif IsDefined("FORM.Exhibition")>
    1
    <cfelse>
    0
  </cfif>
  <cfelseif form.Exhibition eq 0>
  <cfif IsDefined("FORM.Exhibition")>
    0
    <cfelse>
    1
  </cfif>
  </cfif>

and this

<input <cfif (#Artwork.Exhibition# EQ 1)>checked</cfif> name="Exhibition" type="checkbox" id="Exhibition" value="1">

and this

<cfparam name="form.Exhibition" default="0">
0
 
LVL 25

Assisted Solution

by:James Rodgers
James Rodgers earned 25 total points
ID: 9874540
with this

<cfif form.Exhibition eq 1>
  <cfif IsDefined("FORM.Exhibition")>
 you are checking the value before you check for the variables existence, you probably will get into a situation where this will crash

what are you trying to achieve with the code?
0
 
LVL 12

Expert Comment

by:jyokum
ID: 10049751
phillystyle123,
This has been open 33 days and there hasn't been a comment added in 32 days.
Please select a comment as the solution or give us an update.

jyokum
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question