Ask a Question related to Macromedia ColdFusion, Design and Development.
-
Synner #1
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#& recordID=#MDCODE#'>
Select from list </td> </tr> (I have included
&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
-
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... -
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... -
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... -
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... -
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... -
philh #2
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' && document.whatever.p1.checked == true) {phrase =
'This is the first selection';} if (choice == 'p2' &&
document.whatever.p2.checked == true) {phrase = 'This is the second
selection';} if (choice == 'p3' && document.whatever.p3.checked ==
true) {phrase = 'This is the third selection';} if (choice == 'p4' &&
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
-
philh #3
Re: Inserting data from checkboxes on second page.
The emoticons, BTW, are a colon followed by a small letter 'p'.
Whatever.
philh Guest
-
Synner #4
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
-
tphethean #5
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
-
Synner #6
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#& ;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
-
philh #7
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
-
Synner #8
Re: Inserting data from checkboxes on second page.
Hi Phil
Thanks for the suggestions, which enables me to sole this problem.
Nigel
Synner Guest



Reply With Quote

