Skip to main content
Inspiring
December 11, 2007
Question

Redisplay Radio buttons

  • December 11, 2007
  • 1 reply
  • 511 views
My cfform has five checkboxes, <cfinput type="checkbox" name="error_code_1" value="1"> 1, etc.
In my action page, when I insert, they all go into a column named error_code, so it can contain 1-10, 1, 2, 5,. etc. whichever checkboxes were selected.

When I bring the page back up to review, how do I show the all five checkboxes with the check, if one of them was selected ?
    This topic has been closed for replies.

    1 reply

    Inspiring
    December 11, 2007
    trojnfn wrote:
    > My cfform has five checkboxes, <cfinput type="checkbox" name="error_code_1"
    > value="1"> 1, etc.
    > In my action page, when I insert, they all go into a column named error_code,
    > so it can contain 1-10, 1, 2, 5,. etc. whichever checkboxes were selected.
    >
    > When I bring the page back up to review, how do I show the all five checkboxes
    > with the check, if one of them was selected ?
    >

    let me get it straight:
    1) you are storing a comma-delimited list of values in a table column?
    (terrible thing to do, btw, as you will soon find out)
    2) you want to CHECK all 5 boxes if AT LEAST ONE of them has been
    previously checked (i.e. if your check boxes have values 1,2,3,4 & 5,
    and the value in the db is 3, you want all 5 checkboxes displayed as
    checked)?

    i suggest you post your relevant code, both for the form and action page.


    ---
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com
    trojnfnAuthor
    Inspiring
    December 11, 2007
    Here is my code for the checkboxes. At least one must be checked, but all five can also be checked.

    <cfinput type="checkbox" name="error_id_1" id="error_id_1" value="1">Code 1 <br>
    <cfinput type="checkbox" name="error_id_2" id="error_id_2" value="2">Code 2 <br>
    <cfinput type="checkbox" name="error_id_3" id="error_id_3" value="3">Code 3 <br>
    <cfinput type="checkbox" name="error_id_3" id="error_id_3" value="4">Code 4 <br>
    <cfinput type="checkbox" name="error_id_5" id="error_id_5" value="5">Code 5

    In the action page, I check to see if each box is checked or not, then insert into the table.This is for the first one only, but the others follow the same format.

    <cfif isDefined("form.error_id_1")>
    <cfquery name="qryInsert_Error_Log" datasource="logistics">
    Insert into tblUnReceivables_Error_Log
    (error_transaction_id,
    error_id,
    urdn_number,
    error_status)

    values
    ('#error_txn_id#',
    '1',
    '#urdn_number#',
    'active')
    </cfquery>
    </cfif>

    What I want to do and/or see is this : If I retrieve the record using the urdn_number, I want to see all five checkboxes. If the first one was checked, then I want to display it with a check inside the box, if it was not checked, then leave it blank. If the second one was checked, display it with the check inside the box, otherwise leave it blank, etc, all should follow in this format.

    So if urdn-number 99999 had check boxes 1,2, and 5 checked, then 99999 would be in the table three times, one record for each checkbox value. If I retrieve all the info for 99999, I want to display all five checkboxes. Since 1 and 2 were checked, they will have the check inside the box. Three and four would be blank since they were not selected, and five will have the check inside the box.

    That is what I would like to see when I retrieve, but I do not know how to get the info out. A simple query select just gets the first one, in this case 1, and bypasses the rest. I tried using a cloop but it brings back 25 rows, 5 x 5 = 25, so the cloop is in the wrong place or just does not work.

    What do I need to do to get the desired output ?