Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
jolejni #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 database
which outputs images. Each image output contains a checkbox. A user viewing the
output can randomly select any of the displayed images and click Submit. I want
the selected images to display in an output table further down on the page.
Can anyone please shed some light on this? I've attached the code below. Thank
you for much in advance! <cfquery name='Recordset1' datasource='o_db'> SELECT
* FROM dbo.Image </cfquery> <form name='form' method='post' action=''> <table
width='75%' border='1'> <cfoutput query='Recordset1'
startrow='#StartRow_Recordset1#' maxrows='#MaxRows_Recordset1#'> <tr>
<td width='32%'>#Recordset1.ImageID#</td> <td width='24%'><div
align='center'><img src='#Recordset1.Image_Path#' width='50' height='50'>
<input name='checkbox' type='checkbox' value='#Recordset1.ImageID#'>
</div></td> </tr> </cfoutput> <tr>
<td>&nbsp;</td> <td> <div align='center'> <input
type='submit' name='Submit' value='Submit'> </div></td>
<td>&nbsp;</td> </tr> </table> </form> ***I want the selected items to
display here******
jolejni Guest
-
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... -
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... -
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... -
CriticalIM #2
Re: Dynamic Checkboxes
There are several ways to accomplish this, included is a quick and easy
solution. Basically you just run another query when the form is submitted to
only selected the ID's that where check. If you have any problems, let me
know. <cfquery name='Recordset1' datasource='o_db'> SELECT * FROM Image
</cfquery> <cfif IsDefined('Submit')> <cfquery name='Recordset1'
datasource='o_db'> SELECT * FROM Image Where ImageID In(#checkbox#)
</cfquery> <cfif Recordset1.RecordCount> <table width='75%' border='1'>
<cfoutput query='Recordset1'> <tr> <td width='32%'>#Recordset1.ImageID#</td>
<td width='24%'><div align='center'><img src='#Recordset1.Image_Path#'
width='50' height='50'> </div></td> </tr> </cfoutput> <cfelse> Sorry, No
Images Have Been Selected! </cfif> <cfelse> <form name='form' method='post'
action=''> <table width='75%' border='1'> <cfoutput query='Recordset1'
startrow='#StartRow_Recordset1#' maxrows='#MaxRows_Recordset1#'> <tr> <td
width='32%'>#Recordset1.ImageID#</td> <td width='24%'><div align='center'><img
src='#Recordset1.Image_Path#' width='50' height='50'> <input name='checkbox'
type='checkbox' value='#Recordset1.ImageID#'> </div></td> </tr> </cfoutput>
<tr> <td> </td> <td> <div align='center'> <input type='submit' name='Submit'
value='Submit'> </div></td> <td> </td> </tr> </table> </form> </cfif> Allen
CriticalIM Guest
-
blkcop #3
Re: Dynamic Checkboxes
Need to do something similar, but restrict to 1 checkbox being allowed. Found
some javascript that may work but unable to figure out how to convert the
script to match my needed field. Any help will be appreciated. Code I am using
is:
<script>
function countChoices(obj) {
max = 1; // max. number allowed at a time
box1 = obj.form.box1.checked; // your checkboxes here
box2 = obj.form.box2.checked;
count = (box1 ? 1 : 0) + (box2 ? 1 : 0);
if (count > max) {
alert("Oops! You can only choose " + max + " staff member! \nUncheck a name
if you want to pick another.");
obj.checked = false;
}
}
</script>
<cfoutput query="myqry">
<input type="checkbox" name="MOD_#staff_id#" value="Yes"
onClick="countChoices(this)">
</cfoutput>
blkcop Guest
-
Xyrer #4
Dynamic checkboxes
Hi, I'm trying to create a bunch of checkboxes based on a xml file, The idea
would be something like a tree, but with checkboxes instead of the elements
inside a branch of a tree, you know, like:
class 1:
[] topic 1
[] topic 2
[] topic 3
class 2:
[] media 1
[] media 2
[] media 3
The problem is that I haven't seen anything like it and I would not like to
harcode it inside the flex program, I was thinking about using a repeater but I
don't know how to approach this problem so it fits inside the form I have, it's
500px wide, 600px high and the checkboxes would be a lot, the form is already
inside an accordion.
I don't know what other information would be necessary, I appreciate any light
anyone can shed over this, thanks.
Xyrer Guest
-
EvolvedDSM #5
Re: Dynamic checkboxes
Well as far as a repeater goes, you could try something like the code I've got
below. You will need to establish a dataprovider to give your repeater
something to repeat!
This example assumes your table has a column named 'title' (text type) and a
column named 'isChecked' (boolean type). The title column is the title or
description of your table records and the isChecked column signifies the
true/false or yes/no property of your record.
<mx:Repeater dataProvider="{your_dataprovider}" id="repeatid">
<mx:HBox>
<mx:Label text="{repeatid.currentItem.title}"/>
<mx:CheckBox selected="{repeatid.currentItem.isChecked}"/>
</mx:HBox>
</mx:Repeater>
EvolvedDSM Guest
-
ntsiii #6
Re: Dynamic checkboxes
Also, I advise putting your repeated controls into a custom component and
repeat that. Pass in a reference to the entire currentItem, and expose the
item in a public property. This will simplify click handling immensely. I'll
post some example code later.
Tracy
ntsiii Guest
-
Xyrer #7
Re: Dynamic checkboxes
Actually, now that evolvedDSM shows it that way, I would think that advanced
data grid is a better choice, that way I can use a tree, and the checkboxes on
another column, and the space is no problem here.
Am I right? I'm gonna test it and post.
Xyrer Guest
-
ntsiii #8
Re: Dynamic checkboxes
Sure, DataGrid is better if you have a lot of items.
Item Renderers, are a bit tricky. Do not start from scratch, but find an
example an modify it. I have a checkbox example on [url]www.cflex.net[/url].
Tracy
ntsiii Guest



Reply With Quote

