Solved

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

Posted on 2003-12-03
11
162 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 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
Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

 
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

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

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

Suggested Solutions

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

734 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