Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
ldonner #1
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> </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> <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
-
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... -
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... -
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,... -
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... -
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... -
The ScareCrow #2
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
-
ldonner #3
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
& Juliet 99% 3 War & Peace
100% The user clicks Romeo & Juliet 1 War
of the World 97% 2 Romeo & 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 & 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
-
Kronin555 #4
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
-
ldonner #5
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
-
Kurt Eye #6
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
-
Kurt Eye #7
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
-
The ScareCrow #8
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
-
ldonner #9
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
-
The ScareCrow #10
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



Reply With Quote

