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

  1. #1

    Default 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>&amp;nbsp;</td> <td> <div align='center'> <input
    type='submit' name='Submit' value='Submit'> </div></td>
    <td>&amp;nbsp;</td> </tr> </table> </form> ***I want the selected items to
    display here******

    jolejni Guest

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    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: 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

  4. #3

    Default 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

  5. #4

    Default 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

  6. #5

    Default 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

  7. #6

    Default 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

  8. #7

    Default 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

  9. #8

    Default 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

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