[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2003-12-03
11
Medium Priority
?
167 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
Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

650 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