Solved

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

Posted on 2003-12-03
11
157 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
Comment Utility
<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
Comment Utility
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
Comment Utility
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
 
LVL 17

Expert Comment

by:anandkp
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 11

Expert Comment

by:hart
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Time Sheet Help 6 33
Need help with htaccess file 10 52
question about access to website 2 55
spamming  on Hosted svrs? 6 47
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…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now