Inserting data from checkboxes on second page.

Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default Inserting data from checkboxes on second page.

    Hi I have an application where users should be able to insert text into a memo
    field from a set of options presented as a list of checkboxes. What I want to
    happen is that the users go to the main edit page, where they can either type
    text directly into a text box, or click on a link to take them to a second
    page, where they can select a range of standard phrases from a checkbox list.
    On closing the second window, they return to the first to find their choices
    have been inserted into the text box. Code from first page: <tr>
    <td> <strong>Physical Properties : </td> <td> <cfset
    fromlist='Physical'> <a
    href='EDITINSERTmicro.cfm?selected=#fromlist#&amp; recordID=#MDCODE#'>
    Select from list </td> </tr> (I have included
    &amp;recordID=#MDCODE# in the link because I am assuming it will be needed to
    take the user back to the relevant record on leaving the second page) Code
    from second page: <cfquery name='editinsertmicro' datasource='microbes'>
    SELECT * FROM microbesTF WHERE mtfname LIKE '%#URL.selected#%' </cfquery>
    <cfform action='MICROinsertphrase.cfm?recordID=#URL.record ID#' method='POST'>
    <cfoutput query='editinsertmicro'> <table> <tr>
    <td>#mtfname#</font></td> <td> <input name='iselected'
    type='checkbox' value='iselected'> </td> </tr> </table>
    </cfoutput> <table> <tr> <td> <INPUT TYPE='submit'
    VALUE='Confirm'> <INPUT TYPE='reset' VALUE='Clear changes'>
    </td> </tr> </table> </cfform> This sets up the checkboxes. The question
    is how to I collect the users responses and send insert them in the relevant
    field? Any help would be much appreciated. Nigel

    Synner Guest

  2. Similar Questions and Discussions

    1. Inserting checkboxes into DB
      Hello all, I was wondering if anyone out there could help me decipher how to "insert" a checkbox (yes/no) into a MS Access DB? I've got a form...
    2. update page doesn't populate checkboxes
      Hello. I'm using VBScript/ASP, MS-SQL, DW2004MX. I used Dreamweaver's Update Record Form Wizard to create a small update page. When the data...
    3. SQL: Inserting data from table1 with static data into table 2
      Hi, I'm trying to create an SP in SQL Server 2000 that will read in a load of row values and insert them, along with two static values, into...
    4. Populating dynamic checkboxes using query data
      I am building an update form for a table that has checkbox data. How can I populate the checkboxes with data from the table so users can see the...
    5. Inserting into one table data from 2 tables and some input data.
      Alrighty, I pull records from a database table onto a page based on vendor #. On this page I have an input box after each row of data that is just...
  3. #2

    Default Re: Inserting data from checkboxes on second page.

    Hi Nigel, You should be able to do this on one page, or from a popup, without
    reloading pages. Here's a simple example: <!DOCTYPE HTML PUBLIC '-//W3C//DTD
    HTML 4.0 Transitional//EN'> <html> <head> <title>Phrase-In-A-Box</title>
    <script language='JavaScript1.2'> function popphrase(choice) { phrase = ''; if
    (choice == 'p1' &amp;&amp; document.whatever.p1.checked == true) {phrase =
    'This is the first selection';} if (choice == 'p2' &amp;&amp;
    document.whatever.p2.checked == true) {phrase = 'This is the second
    selection';} if (choice == 'p3' &amp;&amp; document.whatever.p3.checked ==
    true) {phrase = 'This is the third selection';} if (choice == 'p4' &amp;&amp;
    document.whatever.p4.checked == true) {phrase = 'This is the fourth
    selection';} if (phrase !== ''){ document.whatever.jabberbox.value =
    document.whatever.jabberbox.value + ' \n'+ phrase; } } </script> </head>
    <body> <form name='whatever' action='post'> <input type='checkbox' name='p1'
    onclick='javascript:popphrase('p1');'>This is the first selection.<br> <input
    type='checkbox' name='p2' onclick='javascript:popphrase('p2');'>This is the
    second selection.<br> <input type='checkbox' name='p3'
    onclick='javascript:popphrase('p3');'>This is the third selection.<br> <input
    type='checkbox' name='p4' onclick='javascript:popphrase('p4');'>This is the
    fourth selection.<br> <textarea name='jabberbox' rows='10' cols='50'>
    </textarea> </form> </body> </html> HTH,

    philh Guest

  4. #3

    Default Re: Inserting data from checkboxes on second page.

    The emoticons, BTW, are a colon followed by a small letter 'p'.

    Whatever.
    philh Guest

  5. #4

    Default Re: Inserting data from checkboxes on second page.

    Hi Phil, this is interesting -- thanks for your suggestions. However, there
    are a couple of issues: my knowledge of Java is limited (almost non-existant!)
    and I'm a bit at a loss as to how to close this dialogue and return to my
    original form. More significantly, you solution, elegant though it is, is based
    on hand-coded checkboxes. In my original idea the checkboxes are created
    dynamically by: <cfquery name='editinsertmicro' datasource='microbes'> SELECT
    * FROM microbesTF WHERE mtfname LIKE '%#URL.selected#%' </cfquery> etc You've
    been very helpful so far, any futher ideas would be most appreciated. Nigel

    Synner Guest

  6. #5

    Default Re: Inserting data from checkboxes on second page.

    You should just be able to set the values of the select query as the value
    attributes of the checkboxes in your second page. 1) Do your select query
    'editinsertmicro' 2) Loop through results of query to create your checkboxes,
    inserting the value from the query: <cfloop query='editinsertmicro'>
    <input name='iselected' type='checkbox'
    value='#editinsertmicro.yourvariablename#'> </cfloop> Then set the submit
    button of the form to post the results through to the first page, and use
    <cfparam name='mytext' default=''> <cfif isdefined('form.checkboxes')> <cfset
    mytext = each of the form check box values > </cfif> Then define your text
    box: <cfinput type='text' value='#mytext#'> Obviously this code will need some
    tidying, but hopefully you get the gist of it. HTH

    tphethean Guest

  7. #6

    Default Re: Inserting data from checkboxes on second page.

    Hi, and thanks for the suggestions which have taken me a long way towards my
    goal! I've now got this code on the second page: <cfform
    action='EDITmicro1.cfm?recordID=#URL.recordID#' method='POST'> <table> <tr>
    <cfloop query='editinsertmicro'> <td>
    <cfoutput>#editinsertmicro.mtfname#</cfoutput> <input name='iselected'
    type='checkbox' value='#editinsertmicro.mtfname#'> </td> </tr> </cfloop>
    </table> <table> <tr> <td> <INPUT TYPE='submit' VALUE='Confirm'> <INPUT
    TYPE='reset' VALUE='Clear changes'> </td> </tr> </table> </cfform> That
    works fine. However, I'm not clear how to implement the rest of your
    suggestions. >>Then set the submit button of the form to post the results
    through to the first page OK, if I do this in the <cfform
    action='EDITmicro1.cfm?recordID=#URL.recordID#&amp ;iselected=#iselected#'
    method='POST'> the system throws an error because it can't find the iselected
    variable? <cfset mytext = each of the form check box values > This line is a
    bit obscure to me (my fault, I assume you!) Thanks Nigel

    Synner Guest

  8. #7

    Default Re: Inserting data from checkboxes on second page.

    Hi Nigel, At the time you render the form page, Iselected is not yet defined;
    it's a form variable. FORM variables are passed in the FORM scope. There's
    no need to append the value to the action page reference in the FORM tag. If
    your action page expects the Iselected variable, it should be in the FORM
    scope, not the URL scope. HTH,

    philh Guest

  9. #8

    Default Re: Inserting data from checkboxes on second page.

    Hi Phil

    Thanks for the suggestions, which enables me to sole this problem.

    Nigel


    Synner 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