Update myTable Set myBitField = 1 Where id IN (#form.CheckBoxName)# Update myTable Set myBitField = 1 Where id NOT IN (#form.CheckBoxName)# Ken [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => The ScareCrow [ip] => info@krcaldwell [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] => 4 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> UPDATE Adult2MB SET Capability="Yes" WHERE ID IN(#FORM.Status#) UPDATE Adult2MB SET Status="No" WHERE ID NOT IN(#FORM.Status#) SELECT * FROM MeritBadges ORDER BY Name DESC SELECT * FROM Adults ORDER BY Name DESC SELECT MB_ID, Adult_ID FROM Adult2MB WHERE MB_ID = '#FORM.MB_ID#' Administration Page
Administration

Update Counselors to Merit Badges
   Adult Name Yes?
  #getAdults.Name#
 
 
[allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => ldonner [ip] => lmdonner@yahoo. [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] => 6 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> UPDATE Adult2MB SET Capability="Yes" WHERE ID IN(#FORM.Status#) UPDATE Adult2MB SET Status="No" WHERE ID NOT IN(#FORM.Status#) Also after the 2 update queries you have a closing tag, but I can't see the opening tag to match. You have the following code While your looping through the getAdults record set you don't loop through the getAdult2MB recordset, so it will only ever check the first record. I think you want to do   #getAdults.Name# checked> Ken [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => The ScareCrow [ip] => info@krcaldwell [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] => 7 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> Reading Dynamic Checkbox values - Coldfusion - Advanced Techniques

Reading Dynamic Checkbox values - Coldfusion - Advanced Techniques

I have a resultset which has a Boolean field that I display in a table, however I am having a problem trying to update the data for these checkboxes. I have used a combination for the checkbox name but I am unable to read the values assigned to the checkboxes due to the inherent nature of FORMS. Does anyone know of a way to display boolean values using checkboxes and change/update the data to the database? Thanks....

  1. #1

    Default Reading Dynamic Checkbox values

    I have a resultset which has a Boolean field that I display in a table, however
    I am having a problem trying to update the data for these checkboxes. I have
    used a combination for the checkbox name but I am unable to read the values
    assigned to the checkboxes due to the inherent nature of FORMS. Does anyone
    know of a way to display boolean values using checkboxes and change/update the
    data to the database?
    Thanks.

    ldonner Guest

  2. #2

    Default Re: Reading Dynamic Checkbox values

    let me see ur code..
    adonis1976 Guest

  3. #3

    Default Re: Reading Dynamic Checkbox values

    For display:
    <input type="checkbox" name="myCheckbox" <cfif myQuery.myCheckbox EQ
    1>checked</cfif>>

    On action page:
    <cfquery....>
    Update myTable
    SET myCheckbox = #IIf(IsDefined("myCheckbox"),1,0)#
    WHERE myID...
    </cfquery>

    mattw Guest

  4. #4

    Default Re: Reading Dynamic Checkbox values

    You need to approch this in 2 ways.

    First thing is to call the checkboxes all the same name. Then in the value
    attribute of the checkbox insert the id of the record.

    Then in the action page

    <!--- Process all the checkboxes that are defined (ie checked) --->
    Update myTable
    Set myBitField = 1
    Where id IN (#form.CheckBoxName)#

    <!--- Process all the checkboxes that are not defined (ie not checked) --->
    Update myTable
    Set myBitField = 1
    Where id NOT IN (#form.CheckBoxName)#

    Ken


    The ScareCrow Guest

  5. #5

    Default Re: Reading Dynamic Checkbox values

    Hi,

    Include <cfparam name="mycheckbox" default="0"> in your action page, before
    the SQL statement.
    If your checkbox is checked it will submit the correct value "1" to your
    action page. If it is not checked then no value is submited and the default
    value from the cfparam is used.

    Cheers,
    Fober


    franzo Guest

  6. #6

    Default Re: Reading Dynamic Checkbox values

    What I am trying to do is show a meritbadge from a menu list that then shows
    all the adult leaders and whether or not they can counsel scouts on that merit
    badge. Here is my code so far.

    Thanks



    <!--- Update all checkboxes that are defined (ie checked) --->
    <cfquery name="updateAdultMDYes" datasource="MySrc">
    UPDATE Adult2MB
    SET Capability="Yes"
    WHERE ID IN(#FORM.Status#)
    </cfquery>
    <!--- Update all checkboxes that are not defined (ie not checked) --->
    <cfquery name="updateAdultMBNo" datasource="MySrc">
    UPDATE Adult2MB
    SET Status="No"
    WHERE ID NOT IN(#FORM.Status#)
    </cfquery>
    </cfif>
    <cfquery name="getMeritBadges" datasource="MySrc">
    SELECT *
    FROM MeritBadges
    ORDER BY Name DESC
    </cfquery>
    <cfquery name="getAdults" datasource="MySrc">
    SELECT *
    FROM Adults
    ORDER BY Name DESC
    </cfquery>
    <cfquery name="getAdult2MB" datasource="MySrc">
    SELECT MB_ID, Adult_ID
    FROM Adult2MB
    WHERE MB_ID = '#FORM.MB_ID#'
    </cfquery>
    <html>
    <head>
    <title>Administration Page</title>
    <meta http-equiv="Content-Type" content="text/html; cht=iso-8859-1">
    <link href="joist.css" rel="stylesheet" type="text/css">
    </head>
    <body>
    <div class="titleCap">Administration</div>
    <br>
    <table width="100%" border="1" cellspacing="0" cellpadding="0">
    <tr align="center">
    <td class="StoryTitle">Update Counselors to Merit Badges</td>
    </tr>
    <tr align="center">
    <td>
    <form method="POST" name="UpdateData">
    <table width="90%" border="0" cellpadding="0" cellspacing="0">
    <tr class="StoryTitle">
    <td width="30%" class="center"><select name="MB_ID"
    onChange="this.form.submit();">
    <cfoutput query="getMeritBadges">
    <option value="#getMeritBadges.ID#" <cfif
    (isDefined("FORM.MB_ID") AND FORM.MB_ID EQ
    getMeritBadges.ID)>selected</cfif>>#getMeritBadges.Name#</option>
    </cfoutput>
    </select>
    &nbsp;&nbsp;</td>
    <td width="30%" class="center">Adult Name</td>
    <td width="30%">Yes?</td>
    </tr>
    <cfoutput query="getAdults">
    <tr>
    <td>&nbsp;</td>
    <td>#getAdults.Name#</td>
    <td>
    <cfif getAdults.ID EQ EQ getAdult2MB.Adult_ID>
    <input name="Status" type="checkbox" value="#getAdults.ID#"
    checked>
    <cfelse>
    <input name="Status" type="checkbox" value="#getAdults.ID#">
    </cfif>
    </td>
    </tr>
    </cfoutput>
    <tr>
    <td colspan="3">&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td colspan="2">
    <input name="UpdateData" type="submit" value="Submit">
    <input name="Reset" type="reset" value="Reset">
    </td>
    </tr>
    </table>
    </form>
    </td>
    </tr>
    </table>
    </body>
    </html>

    ldonner Guest

  7. #7

    Default Re: Reading Dynamic Checkbox values

    You don't indicate if your code is working or giving errors and if errors what
    are they.

    But, it appears that you submit the form back to itself. So you should not be
    doing the db updates unless the form has been submitted.
    <cfif isdefined("form.UpdateData")>
    <!--- Update all checkboxes that are defined (ie checked) --->
    <cfquery name="updateAdultMDYes" datasource="MySrc">
    UPDATE Adult2MB
    SET Capability="Yes"
    WHERE ID IN(#FORM.Status#)
    </cfquery>
    <!--- Update all checkboxes that are not defined (ie not checked) --->
    <cfquery name="updateAdultMBNo" datasource="MySrc">
    UPDATE Adult2MB
    SET Status="No"
    WHERE ID NOT IN(#FORM.Status#)
    </cfquery>
    </cfif>

    Also after the 2 update queries you have a closing </cfif> tag, but I can't
    see the opening tag to match.

    You have the following code
    <cfif getAdults.ID EQ EQ getAdult2MB.Adult_ID>

    While your looping through the getAdults record set you don't loop through the
    getAdult2MB recordset, so it will only ever check the first record. I think
    you want to do

    <cfoutput query="getAdults">
    <tr>
    <td>&nbsp;</td>
    <td>#getAdults.Name#</td>
    <cfloop query="getAdult2MB">
    <td>
    <input name="Status" type="checkbox" value="#getAdults.ID#" <cfif
    getAdults.ID EQ EQ getAdult2MB.Adult_ID>checked</cfif>>
    </td>
    </cfloop>
    </tr>
    </cfoutput>

    Ken

    The ScareCrow Guest

  8. #8

    Default Re: Reading Dynamic Checkbox values

    Trying to do something very similar, but ONLY want them to be able to check 1
    box on the page, which would then (on submit) send user to another page to
    conduct updates of file. All of my checkboxes would have the same name
    (ie-MOD_#id#) as they are being dynamically assigned from a query.

    blkcop Guest

  9. #9

    Default Re: Reading Dynamic Checkbox values

    blkcop,
    Is this a plain html/cfm page ?

    If so you can do this using javascript.
    See code attached, which is untested

    Ken



    function checkOne(clickedBox, totalBoxes){
    for(i=1;i=toalBoxes;i++){
    if(doent.getElementById("MOD_" + i).checked && i != clickedBox){
    // this will uncheck any box that is checked and then check the box
    that was clicked
    doent.getElementById("MOD_" + i).checked = false;
    doent.getElementById("MOD_" + clickedBox).checked = true;
    }
    }
    }
    }

    <!--- then with each checkbox you have an onclick event

    <input type="checkbox" name="MOD_#currentrow#"
    onclick="checkOne('#currentrow#', '#recordcount#');">

    The ScareCrow Guest

Similar Threads

  1. Flash Checkbox values not responding
    By rob36 in forum Coldfusion Flash Integration
    Replies: 0
    Last Post: October 12th, 08:35 PM
  2. How to bind checkbox to one of the values of a datagrid
    By asp123 vbnet via .NET 247 in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: March 26th, 04:36 AM
  3. Inserting multiple checkbox values
    By SharonM in forum Dreamweaver AppDev
    Replies: 1
    Last Post: March 4th, 12:11 AM
  4. pass dynamic checkbox values to results page?
    By Usergroup User webforumsuser@macromedia.com in forum HTML & CSS
    Replies: 8
    Last Post: September 22nd, 06:12 PM
  5. retrieving form checkbox values
    By Caspar Kennerdale in forum PHP Development
    Replies: 2
    Last Post: July 17th, 09:34 AM

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
  •