Deselecting dynamic checkboxes

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Deselecting dynamic checkboxes

    I am quering a database that dynamically creates a table with three columns.
    The first column is the ID, the second is the title of the document and the
    third is a computed value of relevance. The user clicks the title, which
    reloads the page but expands the table below the selected title revealing
    various items (with checkboxes) which are used to compute the third column.
    Initially the checkboxes on each row that are 'checked' or 'true'. What I need
    is to be able to do is deselect an item(s) and have it reload the page with the
    checkboxes still deselected. I can't seem to figure out a way to differentiate
    between the checkboxes. Any ideas? Thanks!

    <form name="PopIn" action="#CGI.SCRIPT_NAME#?ID=#listIDs.IDNumber#### IDNum#"
    method="post">
    <tr>
    <!--- Layout spacer (ID number) --->
    <td>&nbsp;</td>
    <td>
    <!--- Pop-in table --->
    <table width="100%" border="1" align="center" cellpadding="0"
    cellspacing="0">
    <!--- Pop-in title row --->
    <tr>
    <th width="50%">Critics</th>
    <th width="50%" colspan="3">Organization</th>
    </tr>
    <!--- Array to hold Critic/Publication percent in PopIn --->
    <cfset popInArray=ArrayNew(1)>
    <!--- Index variable --->
    <cfset z = 1>
    <!--- Loop through resultset and dynamically display results in table rows
    --->
    <cfloop query="listCriticsPubs">
    <!--- Set groupings for both Assets and Targets --->
    <cfset CriticID = #listCriticPub.CriticName# & "-" & #listCriticPub.Org#>
    <cfset PubID = #listCriticPub.PubName# & "-" & #listCriticPub.ID#>
    <tr>
    <!--- Check if Critic/Publication combo repeats and display it only once
    --->
    <cfif #CriticGroup# NEQ #CriticID#>
    <td>
    <input name="cb_Asset" type="checkbox" value="true" checked>
    #listCriticPub.CriticName# (#listCriticPub.Org#)</td>
    <cfset PopInArray[z]=#listCriticPub.Percent#>
    <cfelse>
    <!--- Display empty cell --->
    <td>&nbsp;<input name="cb_Asset" type="hidden" value="false"></td>
    <cfset PopInArray[z]=#listCriticPub.Percent#>
    </cfif>
    <td>
    <input name="cb_Target" type="checkbox" value="true" checked>
    #listCriticPub.PubName# (#listCriticPub.ID#) -
    #listCriticPub.Percent#%</td>
    </tr>
    <!--- Set temporary variables for Critic and Org for display check above --->
    <cfset AssetGroup = #listCriticPub.CriticName# & "-" & #listCriticPub.Org#>
    <cfset TargetGroup = #listCriticPub.PubName# & "-" & #listCriticPub.ID#>
    <cfset z = z + 1>
    </cfloop>
    <!--- End loop through resultset and dynamically display results in table
    rows --->
    <!--- Display options for pop-in --->
    <tr>
    <td class="center" colspan="2">
    <input name="PopIn" type="submit" value="What if">
    <input name="PopIn" type="submit" value="Reset" onClick="check()">
    <input name="PopIn" type="submit" value="Apply Globally">
    <input name="PopIn" type="submit" value="Hide PopIn">
    </td>
    </tr>
    </table>
    <!--- End Pop-in table --->
    </td>
    <td class="top">
    <table width="100%" border="0" align="center" cellpadding="0"
    cellspacing="0">
    <tr>
    <cfset ReqSuccess = 0>
    <cfset isSuccessful = ArraySort(PopInArray, "numeric", "desc")>
    <td>
    <table><tr><td class="top">
    <cfloop index="z" from="1" to="#ArrayLen(PopInArray)#">
    <cfif PopInArray[z] NEQ 0>
    <cfset ReqSuccess = tempSum(ReqSuccess, PopInArray[z])>
    </cfif>
    </cfloop>
    <cfset postReqSuccess = #Evaluate(Round(ReqSuccess*100))#>
    #postReqSuccess#%</td></tr></table>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </form>

    ldonner Guest

  2. Similar Questions and Discussions

    1. Dynamic Checkboxes
      This is a rather simple situation that is killing my brain, maybe because I'm working on a Sunday night?! Anyhow, I am running a query against my...
    2. Help on processing a dynamic set of checkboxes
      Hello everyone! I am having a doozy of a time trying to figure out how to process some checkboxes that are dynamically created. Here is my...
    3. Dynamic Checkboxes in Rich Forms
      Hi, I am just in the process of working with rich forms in CF MX7. I am trying to display checkboxes created from a query. The form is displayed,...
    4. Dynamic checkboxes and INSERT into DB
      "Frank Collins" <fcollins@mhca.com> wrote in message news:094101c352a8$7ca66990$a401280a@phx.gbl... Hmm..so you get your companyID on the same...
    5. Dynamic checkboxes & INSERT into DB
      Can anyone point me to some good examples on the web of using values from dynamically created checkboxes on forms in ASP, particularly relating to...
  3. #2

    Default Re: Deselecting dynamic checkboxes

    When the page reloads (posts back to itself)

    Check to see if the checkbox is defined, if it is then it should be checked, if it is not then it should not be checked.

    Ken
    The ScareCrow Guest

  4. #3

    Default Re: Deselecting dynamic checkboxes

    That was my first idea, however the checkbox on each row is defined and checked
    when the link is clicked and the page expands to show the critics/pubs.
    Example: 1 War of the World 97% 2 Romeo
    &amp; Juliet 99% 3 War &amp; Peace
    100% The user clicks Romeo &amp; Juliet 1 War
    of the World 97% 2 Romeo &amp; Juliet
    99% John Smith
    New York Times - 85%
    Chicago Tribune - 90% Bill Jones
    New York Times - 93% Sam Williams New York
    Times - 96%
    Houston Chronicle - 90% 3 War &amp; Peace
    100% * the space under John Smith and Sam Williams indicates a repeat
    article. Each Critic has a checkbox beside them so as to remove their critique
    of a publication/play/movie/etc. thereby changing the overall rating for that
    event. This is an attempt to validate critics and their work (whether bias is
    a factor). When a Critic is deselected all references are removed from the
    calculations showing a new overall percentage as if his critiques were not even
    considered. This can be expanded to all works if the user clicks the Apply
    Globally button instead of the What If button. Thanks.

    ldonner Guest

  5. #4

    Default Re: Deselecting dynamic checkboxes

    The problem is that all your checkboxes have the same name (cb_Asset and
    cb_Target). You have to make the checkbox names unique if you want to
    differentiate between them. You can do that several ways, but it all depends on
    how you want to track it. You could do:
    cb_Asset_#z#
    and
    cb_Target_#z#
    then you obviously have to modify your processing code to handle the different
    names.


    Kronin555 Guest

  6. #5

    Default Re: Deselecting dynamic checkboxes

    I tried that but I can't seem to be able to call the FORM.cb_#AssetID#. I keep
    getting an error stating that the server can't find 'FORM.cb_'. I initially
    tried <input name='#AssetID#' type='checkbox' value'#AssetID# checked> but when
    I tried to call the FORM variable I received an error stating that FORM could
    not end with a period. it seems to be ignoring the #AssetID# altogether. I
    tried using Evaluate but haven't gotten anywhere with it. Thanks for the help.
    I'll just go back and bang my head some more.

    ldonner Guest

  7. #6

    Default Re: Deselecting dynamic checkboxes

    Looks like you aren't setting the "checked" attribute in any way for your INPUT checkboxes.

    <input name="cb_#z#" type="checkbox" value="#z#"> <cfif something EQ something>checked</cfif>>
    Kurt Eye Guest

  8. #7

    Default Re: Deselecting dynamic checkboxes

    Looks like you aren't setting the "checked" attribute in any way for your INPUT checkboxes.

    <input name="cb_#z#" type="checkbox" value="#z#" <cfif something EQ something>checked</cfif>>
    Kurt Eye Guest

  9. #8

    Default Re: Deselecting dynamic checkboxes

    Kurt Eye is correct, but your isdefined statement gave me errors as well.

    Attached code is a working copy.

    Ken

    <html>
    <head>
    <title>Dynamic Variable Tester</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link href="joist.css" rel="stylesheet" type="text/css">
    </head>
    <body>
    <cfoutput>
    <form name="PopIn" action="#CGI.SCRIPT_NAME#" method="post">
    <table width="100%">
    <cfloop index="z" list="1,2,3,4,5,6,7,8,9,10" delimiters="," >
    <tr>
    <td>
    <input name="cb_#z#" type="checkbox" value="#z#" <cfif
    isDefined("FORM.cb_" & z)>checked</cfif>> - #z#</td>
    </tr>
    </cfloop>
    <tr>
    <td>
    You selected the following items: <cfloop index="z" from="1" to="10">
    <cfif isDefined("FORM.cb_" & z)>#FORM['cb_' & z]#</cfif>
    </cfloop>
    </td>
    </tr>
    <tr>
    <td><input name="submit" type="submit" value="submit">
    </td>
    </tr>
    </table>
    </form>
    </cfoutput>
    </body>
    </html>

    The ScareCrow Guest

  10. #9

    Default Re: Deselecting dynamic checkboxes

    Ken (and Kurt), Thanks, that helps. I knew I was missing that but I was
    trying to get it to have all items selected initially and then deselect the
    item(s) retaining the rest as selected. I changed the isDefined to NOT
    isDefined but that doesn't work. So I will keep trying. Again thanks for the
    help.

    ldonner Guest

  11. #10

    Default Re: Deselecting dynamic checkboxes

    no problem, here ya go

    Ken

    <cfparam name="ischecked" default="checked">
    <cfoutput>
    <form name="PopIn" action="#CGI.SCRIPT_NAME#" method="post">
    <table width="100%">
    <cfloop index="z" list="1,2,3,4,5,6,7,8,9,10" delimiters="," >
    <cfif IsDefined("form.submit") And Not IsDefined("FORM.cb_" & z)>
    <cfset ischecked = "">
    <cfelse>
    <cfset ischecked = "checked">
    </cfif>
    <tr>
    <td>
    <input name="cb_#z#" type="checkbox" value="#z#" #ischecked#> -
    #z#</td>
    </tr>
    </cfloop>
    <tr>
    <td>
    You selected the following items: <cfloop index="z" from="1" to="10">
    <cfif isDefined("FORM.cb_" & z)>#FORM['cb_' & z]#</cfif>
    </cfloop>
    </td>
    </tr>
    <tr>
    <td><input name="submit" type="submit" value="submit">
    </td>
    </tr>
    </table>
    </form>
    </cfoutput>

    The ScareCrow Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139