?
Solved

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

Posted on 2003-12-03
11
Medium Priority
?
164 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 17

Accepted Solution

by:
Tacobell777 earned 100 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 100 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
10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

 
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 100 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

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

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

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

777 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