Need Help Processing Checkbox Form Elements

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

  1. #1

    Default Need Help Processing Checkbox Form Elements

    What I'm doing: I'm pulling news releases form an SQL DB that have a status
    of 0. I'm using CFOUTPUT QUERY to output all the records into a table. Each
    record result has its own checkbox that if isDefined onSubmit will set the
    news release status to 1. In effect activating the record. Now since I'm
    using an cfoutput query, I have to increment the checkbox names using a
    counter, ie.. nr1, nr2, nr3 etc...

    My question: How can I dynamically evaluate the checkboxes to see if they
    are defined and update my DB? I need it to be dynamic because the number of
    news releases needing activation will change constantly.

    The following is how I'm creating my checkboxes:

    <cfset checkBoxIncrement = 1>
    <cfoutput query="getFiles">
    <cfset checkBoxIncrement = checkBoxIncrement + 1>
    <cfinput type="checkbox" name="nr#checkboxincrement#" value="#getFiles.id#">
    </cfoutput>

    My update query should look something like this:
    <cfif isDefined("form.submit")>
    <cfquery DATASOURCE="myDS" name="SetNRStatus">
    UPDATE newsreleases
    set status = 1
    where (ID = '#????#') <!---How can I pull all the ID's that are checked?--->
    </cfquery>
    </cfif>

    Thanks.


    bforce Guest

  2. Similar Questions and Discussions

    1. Form Processing Applications
      I have not had much experience with forms processing, but need to build one for a site. I saw a link to Kmita-mail (http://www1.kmita-mail.com/)...
    2. Processing multiple checkbox responses
      I'm now at my wits end on this- A question on a test has 2 correct answers, "ans_b" and "ans_c". In the DB, the "ans_correct" field contains...
    3. Html form processing
      I have been trying this for a few days now. I seem to get parts of it, but I can't get the full scenario to work. I have a page that has an email...
    4. Form Processing
      Hi, I am designing a basic email form using Dreamweaver and the checks are successful. Does Dreamweaver have any functionality to enable me to...
    5. More form processing
      Hey folks, I need some of your expertiese again. I am creating a survey form and need some help gathering the results of a question that has...
  3. #2

    Default Re: Need Help Processing Checkbox Form Elements

    Here's a solution that might be much simpler.

    When you have multiple checkboxes on a form, all with the same name, then the
    submitted value will be all the values of the checked checkboxes.

    ie:

    <form name="testing">
    News Release 3 <input type="checkbox" name="newsreleaseactivate" value="3"><br>
    News Release 5 <input type="checkbox" name="newsreleaseactivate" value="5"><br>
    News Release 12 <input type="checkbox" name="newsreleaseactivate"
    value="12"><br>
    News Release 23 <input type="checkbox" name="newsreleaseactivate"
    value="23"><br>
    <input type="submit" name="submit" value="submit">
    </form>

    If you check News Release 3 and News Release 12 and submit, the value of
    FORM.newsreleaseactivate will be "3,12"

    Then all you need to do is change your query from:
    where (ID = '#????#') <!---How can I pull all the ID's that are checked?--->
    to:
    where id in (#FORM.newsreleaseactivate#)

    Kronin555 Guest

  4. #3

    Default Re: Need Help Processing Checkbox Form Elements

    Worked like a charm. Thanks.
    "Kronin555" <webforumsuser@macromedia.com> wrote in message
    news:d4rggv$l4e$1@forums.macromedia.com...
    > Here's a solution that might be much simpler.
    >
    > When you have multiple checkboxes on a form, all with the same name, then
    > the
    > submitted value will be all the values of the checked checkboxes.
    >
    > ie:
    >
    > <form name="testing">
    > News Release 3 <input type="checkbox" name="newsreleaseactivate"
    > value="3"><br>
    > News Release 5 <input type="checkbox" name="newsreleaseactivate"
    > value="5"><br>
    > News Release 12 <input type="checkbox" name="newsreleaseactivate"
    > value="12"><br>
    > News Release 23 <input type="checkbox" name="newsreleaseactivate"
    > value="23"><br>
    > <input type="submit" name="submit" value="submit">
    > </form>
    >
    > If you check News Release 3 and News Release 12 and submit, the value of
    > FORM.newsreleaseactivate will be "3,12"
    >
    > Then all you need to do is change your query from:
    > where (ID = '#????#') <!---How can I pull all the ID's that are
    > checked?--->
    > to:
    > where id in (#FORM.newsreleaseactivate#)
    >

    bforce Guest

  5. #4

    Default Re: Need Help Processing Checkbox Form Elements

    Oops! I started playing around with this and realized that the checkboxes
    are always going to be defined because they will always be pulling an id
    from the DB. So even if I do not check the boxes and submit the form, the
    query runs and updates the status field. Not what I want to have happen. I'm
    going to have to go another route. Perhaps a list menu.

    <cfif isDefined("form.submit")>
    <cfif isDefined("form.nr")>
    <cfquery DATASOURCE="myDataSource" name="myQuery">
    UPDATE newsreleases
    set status = 1,
    pdfPath = 'PDFDocs/#getFiles.PDFname#',
    image = 'images/#getFiles.imagename#'
    where id in (#FORM.nr#)
    </cfquery>


    "bforce" <bforce@poultryegg.org> wrote in message
    news:d4rdqs$hbe$1@forums.macromedia.com...
    > What I'm doing: I'm pulling news releases form an SQL DB that have a
    > status of 0. I'm using CFOUTPUT QUERY to output all the records into a
    > table. Each record result has its own checkbox that if isDefined onSubmit
    > will set the news release status to 1. In effect activating the record.
    > Now since I'm using an cfoutput query, I have to increment the checkbox
    > names using a counter, ie.. nr1, nr2, nr3 etc...
    >
    > My question: How can I dynamically evaluate the checkboxes to see if they
    > are defined and update my DB? I need it to be dynamic because the number
    > of news releases needing activation will change constantly.
    >
    > The following is how I'm creating my checkboxes:
    >
    > <cfset checkBoxIncrement = 1>
    > <cfoutput query="getFiles">
    > <cfset checkBoxIncrement = checkBoxIncrement + 1>
    > <cfinput type="checkbox" name="nr#checkboxincrement#"
    > value="#getFiles.id#">
    > </cfoutput>
    >
    > My update query should look something like this:
    > <cfif isDefined("form.submit")>
    > <cfquery DATASOURCE="myDS" name="SetNRStatus">
    > UPDATE newsreleases
    > set status = 1
    > where (ID = '#????#') <!---How can I pull all the ID's that are
    > checked?--->
    > </cfquery>
    > </cfif>
    >
    > Thanks.
    >

    bforce 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