> I have the following issue. I had to create a form which is
> populated from a query which can return multiple rows, one
> of the form elements is a Checkbox which is used to select
> a row or rows from the form to run a succeeding select query.
> Our users needed to capability to select or deselect all
> check boxes at once and with help from CF-Talk we solved this
> issue using JavaScript and cfloop. The snag is that in a
> multiple line form each checkbox now has a unique value as
> a result of this code: -
>
> <td><input type="Checkbox" name="C#loopCount#"
> value="#SVC_ADDR_ID#"></td>
>
> The C#loopCount# means that each checkbox has a different name
> when it passed to the next query and the query obviously needs a
> fixed checkbox name to interpret the form.checkbox var passed to
> it. It's Catch22!
>
> Anyone got any ideas on this? and I hope I described this clearly.
Rather than solve the problem you're having now, I'll raise a solution to a
different problem.
You mention that you're using unique checkbox names to make an interface
that allows you to select and deselect all checkboxes at once. You don't
need to do this. You can use the same name for your individual checkboxes
(with different values, of course), and bind an event handler to another
checkbox; this event handler would then loop through the length of your
target checkbox array, and set the checked property for each array member to
true:
<script>
function checkEmAll(mychkboxarray) {
for (i = 0; i < mychkboxarray.length; i++) {
mychkboxarray[i].checked = true;
}
}
</script>
..
Check all:
<input type="checkbox" name="CheckTheOtherBoxes"
onclick="checkEmAll(document.forms[0].mycheckbox);"><br>
Item 1: <input type="checkbox" name="mycheckbox" value="1"><br>
Item 2: <input type="checkbox" name="mycheckbox" value="2"><br>
..
Note that this solution makes sense to use if you really want to return a
list of checked items, like you'd get with a multi-select box. Note also
that I may have made a typo in the above sample; I just typed it in the mail
client, so you're getting exactly what you pay for. Enjoy!
Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444
______________________________________________________________________
Get Your Own Dedicated Windows 2000 Server
PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
Instant Activation � $99/Month � Free Setup
http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists