UPDATE Aged_Care_Facility_Details SET High_Residential_Care_Booked_Respite_Program = #form.High_Residential_Care_Booked_Respite_Program# WHERE ID = #form.ID# [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => mxstu [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 13 [islastshown] => 1 [isfirstshown] => [attachments] => [allattachments] => ) --> update check boxes - Coldfusion - Advanced Techniques

update check boxes - Coldfusion - Advanced Techniques

i have check boxes on a database input form, which shows if there is a yes in the column, this works fine, but i need the the user to be able to untick and tick the boxes to update the table which isnt happening at the min, i have text fields aswell they work fine and update fine many thanks Craig <form action="Update.cfm" method="post"> <cfset checked = "" /> <cfif GetDetails.High_Residential_Care_Booked_Respite_Pr ogram IS "yes"> <cfset checked = "checked" /> </cfif> <input name="High_Residential_Care_Booked_Respite_Program " type="checkbox" value="#GetDetails.High_Residential_Care_Booked_Re spite_Program#" #checked#> <input type="text" name="FacilityName" required="Yes" message="Please enter Facility Name!" value="#FacilityName#"> <input type="SUBMIT" value="Update">...

  1. #1

    Default update check boxes

    i have check boxes on a database input form, which shows if there is a yes in
    the column, this works fine, but i need the the user to be able to untick and
    tick the boxes to update the table which isnt happening at the min, i have text
    fields aswell they work fine and update fine

    many thanks
    Craig

    <form action="Update.cfm" method="post">

    <cfset checked = "" />
    <cfif GetDetails.High_Residential_Care_Booked_Respite_Pr ogram IS "yes">
    <cfset checked = "checked" />
    </cfif>
    <input name="High_Residential_Care_Booked_Respite_Program " type="checkbox"
    value="#GetDetails.High_Residential_Care_Booked_Re spite_Program#" #checked#>

    <input type="text" name="FacilityName" required="Yes" message="Please enter
    Facility Name!" value="#FacilityName#">

    <input type="SUBMIT" value="Update">

    macca2727 Guest

  2. #2

    Default Re: update check boxes

    Hi

    I think when u submit a form, which is having a check box, it wont be sumit
    that control.

    for this in the form action page you can do this:
    <cfparam name="form.High_Residential_Care_Booked_Respite_Pr ogram"
    default="false">

    so when the user submits it, it works fine.

    vkunirs Guest

  3. #3

    Default Re: update check boxes

    macca2727,

    VKUNIRS is correct. Checkboxes and radio buttons are only defined on the
    action page if they were checked. If they are not checked, and you try to
    access the value on the action page, you will get some type of "Element xx
    is undefined" message.

    Either use CFPARAM to set a default in case the box was not checked (as
    VKUNIRS suggested) or use the IsDefined() function.



    mxstu Guest

  4. #4

    Default Re: update check boxes

    ok so in my action page i have used the following but still didnt work, is my
    code correct?


    <cfupdate datasource="DPSGuide" tablename="Aged_Care_Facility_Details">
    <cfparam name="form.High_Residential_Care_Booked_Respite_Pr ogram"
    default="false">

    macca2727 Guest

  5. #5

    Default Re: update check boxes

    I'm not sure what the checkbox value should be, but move the CFPARAM before the CFUPDATE.
    mxstu Guest

  6. #6

    Default Re: update check boxes

    ok i have tried that, still no luck.

    i have attached the code relevant

    <cfoutput>
    <form action="Update.cfm" method="post">
    <input type="hidden" name="ID" value="#GetDetails.ID#">

    Booked Respite:
    <cfset checked = "" />
    <cfif GetDetails.High_Residential_Care_Booked_Respite_Pr ogram IS "yes">
    <cfset checked = "checked" />
    </cfif>
    <input name="High_Residential_Care_Booked_Respite_Program " type="checkbox"
    value="#GetDetails.High_Residential_Care_Booked_Re spite_Program#" #checked#>
    </form>
    </cfoutput>

    Update.cfm
    <cfparam name="High_Residential_Care_Booked_Respite_Program " default="false">
    <cfupdate datasource="DPSGuide" tablename="Aged_Care_Facility_Details">

    macca2727 Guest

  7. #7

    Default Re: update check boxes

    macca2727,

    Actually, if the column in your table has a YES/NO data type then what you
    want to do is set the checkbox value to "YES" in your form. Then on the action
    page, use CFPARAM to set the default to "NO".

    So if the box is checked, the table column will be set to YES. Otherwise it
    will be set to NO (ie. unchecked).

    mxstu Guest

  8. #8

    Default Re: update check boxes

    yes table column is YES/NO
    ok that works if the user changes the value from not ticked to ticked and
    updates fine,
    but if the box is already ticked and the user unticks it, it dosnt update the
    database?



    macca2727 Guest

  9. #9

    Default Re: update check boxes

    Did you change the CFPARAM default to NO?
    jdeline Guest

  10. #10

    Default Re: update check boxes

    Put a hidden field with the same name as the checkbox right before the
    checkbox. Give it a value of No and give your checkbox a value of Yes. When
    you update your database, use the listlast function.

    Originally posted by: macca2727
    yes table column is YES/NO
    ok that works if the user changes the value from not ticked to ticked and
    updates fine,
    but if the box is already ticked and the user unticks it, it dosnt update the
    database?





    Dan Guest

  11. #11

    Default Re: update check boxes

    Originally posted by: macca2727
    yes table column is YES/NO
    ok that works if the user changes the value from not ticked to ticked and
    updates fine,
    but if the box is already ticked and the user unticks it, it dosnt update the
    database?


    I suspect maybe you haven't changed your form code to the correct value? The
    checkbox value in your form should always be "YES" (not set to the current
    value from the database). Then on the action page, use CFPARAM to set the
    default to "NO". This will update your YES/NO database column correctly.



    mxstu Guest

  12. #12

    Default Re: update check boxes

    i have attached my code i think its right, but i still cant uncheck a box and
    it updates the table to NO
    it work when you tick the box fine

    FORM
    <cfset checked = "" />
    <cfif GetDetails.High_Residential_Care_Booked_Respite_Pr ogram IS "yes">
    <cfset checked = "checked" />
    </cfif>
    <input name="High_Residential_Care_Booked_Respite_Program " type="checkbox"
    value="YES" #checked#>

    UPDATE.CFM
    <cfparam name="High_Residential_Care_Booked_Respite_Program " default="NO">
    <cfupdate datasource="DPSGuide" tablename="Aged_Care_Facility_Details">

    macca2727 Guest

  13. #13

    Default Re: update check boxes

    Originally posted by: macca2727
    i have attached my code i think its right, but i still cant uncheck a box and
    it updates the table to NO
    it work when you tick the box fine

    The attached code works fine for me. You can also just use cfquery. Note -
    Afaik cfquery returns the value of a yes/no field as 1 or 0 not yes or no, so
    you need to change your CFIF statement.



    <!--- form page --->
    <form action="update.cfm" method="post">
    <form action="Update.cfm" method="post">
    <input type="hidden" name="ID" value="#getDetails.ID#">

    <cfset checked = "" />
    <cfif getDetails.High_Residential_Care_Booked_Respite_Pr ogram eq 1> <!----
    YES --->
    <cfset checked = "checked" />
    </cfif>
    <input name="High_Residential_Care_Booked_Respite_Program " type="checkbox"
    value="YES" #checked#>
    <input type="submit">
    </form>
    </cfoutput>

    <!--- update.cfm --->
    <cfparam name="form.High_Residential_Care_Booked_Respite_Pr ogram" default="NO">
    <cfupdate datasource="#yourDSN#" tablename="Aged_Care_Facility_Details"
    formfields="ID,High_Residential_Care_Booked_Respit e_Program">

    <!--- alternative to cfupdate --->
    <cfparam name="form.High_Residential_Care_Booked_Respite_Pr ogram"
    default="NO">
    <!--- should use cfqueryparam with "form" values --->
    <cfquery name="updateSetting" datasource="#yourDSN#">
    UPDATE Aged_Care_Facility_Details
    SET High_Residential_Care_Booked_Respite_Program =
    #form.High_Residential_Care_Booked_Respite_Program #
    WHERE ID = #form.ID#
    </cfquery>

    mxstu Guest

Similar Threads

  1. Check boxes -Update many Items
    By terryt in forum Coldfusion - Getting Started
    Replies: 3
    Last Post: June 3rd, 01:58 PM
  2. Check Boxes
    By Claude Carlos in forum Adobe Acrobat Windows
    Replies: 14
    Last Post: April 29th, 10:17 PM
  3. P. S. re check boxes
    By K in forum Web Design
    Replies: 1
    Last Post: February 22nd, 03:24 PM
  4. Check to see if Check Boxes are Checked
    By Lyn in forum ASP Database
    Replies: 2
    Last Post: December 15th, 06:00 PM
  5. Check boxes
    By Nathan in forum Microsoft Access
    Replies: 2
    Last Post: September 15th, 03:37 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •