Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

defining default values for lots of checkboxes

Status
Not open for further replies.

romeo23

Technical User
May 28, 2004
5
US
Hi, I have an online form where I'm defining default values for checkboxes. I'm doing this on the server side page with the following code:
<cfparam name="the_name" value="">
This works fine for a couple of checkboxes but I have about a hundred. I was wondering if there was a way to do this by just setting a default value for all the checkboxes. Or maybe having an array pull in all the checkboxes and give them a default value

Does anyone know how to do this. I've searched the web for a long time with no luck. I appreiciate the help. Thanks.
 
Can we see some code? soem of the form code and exactly what you're doing with the checkboxes (action page)?

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
sounds like you need a loop of some kind. if you have the values in a database that would work good but if not i would creat an array hardcoded on the page (second choice mind you, db first) array syntax may be a little off i don't use them much.

<cfset myArray = arrayNew(1)>
<cfset myArray[1] = "bob">
<cfset myArray[2] = "Joe">
<cfset myArray[3] = "Allan">
..
..
..
<cfset myArray[99] = "Bill">
<cfset myArray[100] = "Robert">

loop through the array
<cfloop from = "1" to = "#arrayLen(myArray)#" index = "myValue">
<input type = "checkbox" name = "the_name" value = "<cfoutput>#myArray[myValue]#</cfoutput>"><br>
</cfloop>

Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)
 
Ok, I got back from the long weekend. Here is some of the code that is on the page so you can get a better idea of what is going on and what I want to do.

The first segment of code below is the actual html page where the people will be checking the checkboxes. The next segment of code will be the coldfusion page that processes the page.

<cfform method="post" name="form" action="app_send.cfm">

<tr><td colspan="2"><strong>Community/Volunteer/Work Activities<br> (Please indicate number of hours per week)</strong></td><td>9</td><td>10</td><td>11</td><td>12</td><td>PG</td><td>Participate in College?</td></tr>
<tr><td colspan="2"><input type="text" name="comm1" size="40"></td><td><input type="checkbox" name="comm19check" value="x"></td><td><input type="checkbox" name="comm110check" value="x"></td><td><input type=checkbox name="comm111check" value="x"></td><td><input type="checkbox" name="comm112check" value="x"></td><td><input type="checkbox" name="comm1pgcheck" value="x"></td><td><input type="checkbox" name="comm1partcheck" value="x"></td></tr>
<tr><td colspan="2"><input type="text" name="comm2" size=40></td><td><input type="checkbox" name="comm29check" value="x" ></td><td><input type="checkbox" name="comm210check" value="x"></td><td><input type="checkbox" name="comm211check" value="x"></td><td><input type="checkbox" name="comm212check" value="x"></td><td><input type="checkbox" name="comm2pgcheck" value="x"></td><td><input type="checkbox" name="comm2partcheck" value="x"></td></tr>
</table>
**************************************
* The above code goes on in the same *
* way for quite awhile. *
**************************************
<td align="right"><input type="image" src="/images/submit.gif" width="50" height="19" border="0" alt="Submit">
</cfform>

[highlight]
Ok, that was the first segment of code.
Here is the second segment which is also the coldfusion backend page.[/highlight]

[highlight]This is the only way I have figured out that I can get the page to go through, but I don't want to have hundreds of lines like this, plus there has got to be a better way to solve this problem.
<cfparam name="form.comm19check" default="">[/highlight]
<cfmail from = "#form.FNAME# #form.LNAME# <mail@mail.edu>"
to = "mail@mail.edu"
subject = "Online Application">

<cfmailpart type="html">
<h2>Online Application</h2>
<table width="640" cellspacing="0" cellpadding="5" border="0" style="font-family:times new roman;font-size:14px;">

<tr>
<td colspan="2">
<!-- Start of School/Work/Community Activities Data !-->
<table width="100%" cellspacing="1" cellpadding="5" border="0" bgcolor="004730" style="font-family:times new roman;font-size:14px;">
<tr>
<td colspan="8"><strong><font color="FFFFFF">Community/Volunteer/Work Activities</font></strong></td>
</tr>
<tr>
<td colspan="2" bgcolor="FFFFFF"> #form.comm1#</td><td bgcolor="FFFFFF">#form.comm19check#</td><td bgcolor="FFFFFF">#form.comm110check#</td><td bgcolor="FFFFFF">#form.comm111check#</td><td bgcolor="FFFFFF">#form.comm112check#</td><td bgcolor="FFFFFF">#form.comm1pgcheck#</td><td bgcolor="FFFFFF">#form.comm1partcheck#</td>
</tr>
<tr>
<td colspan="2" bgcolor="FFFFFF"> #form.comm2# </td><td bgcolor="FFFFFF">#form.comm29check#</td><td bgcolor="FFFFFF">#form.comm210check#</td><td bgcolor="FFFFFF">#form.comm211check#</td><td bgcolor="FFFFFF">#form.comm212check#</td><td bgcolor="FFFFFF">#form.comm2pgcheck#</td><td bgcolor="FFFFFF">#form.comm2partcheck#</td>
</tr>
<tr>
<td colspan="2" bgcolor="FFFFFF"> #form.comm3# </td><td bgcolor="FFFFFF">#form.comm39check#</td><td bgcolor="FFFFFF">#form.comm310check#</td><td bgcolor="FFFFFF">#form.comm311check#</td><td bgcolor="FFFFFF">#form.comm312check#</td><td bgcolor="FFFFFF">#form.comm3pgcheck#</td><td bgcolor="FFFFFF">#form.comm3partcheck#</td>
</tr>
<tr>
<td bgcolor="FFFFFF"><strong>School Clubs and Activities</strong> </td><td bgcolor="FFFFFF">Offices Held</td><td bgcolor="FFFFFF">9</td><td bgcolor="FFFFFF">10</td><td bgcolor="FFFFFF">11</td><td bgcolor="FFFFFF">12</td><td bgcolor="FFFFFF">PG</td><td bgcolor="FFFFFF">Participate in College?</td>
</tr>
<tr>
<td bgcolor="FFFFFF"> #form.club1# </td><td bgcolor="FFFFFF">#form.club1off#</td><td bgcolor="FFFFFF">#form.club19check#</td><td bgcolor="FFFFFF">#form.club110check#</td><td bgcolor="FFFFFF">#form.club111check#</td><td bgcolor="FFFFFF">#form.club112check#</td><td bgcolor="FFFFFF">#form.club1pgcheck#</td><td bgcolor="FFFFFF">#form.club1partcheck#</td>
</tr>
<tr>
<td bgcolor="FFFFFF"> #form.club2# </td><td bgcolor="FFFFFF">#form.club2off#</td><td bgcolor="FFFFFF">#form.club29check#</td><td bgcolor="FFFFFF">#form.club210check#</td><td bgcolor="FFFFFF">#form.club211check#</td><td bgcolor="FFFFFF">#form.club212check#</td><td bgcolor="FFFFFF">#form.club2pgcheck#</td><td bgcolor="FFFFFF">#form.club2partcheck#</td>
</tr>
<tr>
<td bgcolor="FFFFFF"> #form.club3# </td><td bgcolor="FFFFFF">#form.club3off#</td><td bgcolor="FFFFFF">#form.club39check#</td><td bgcolor="FFFFFF">#form.club310check#</td><td bgcolor="FFFFFF">#form.club311check#</td><td bgcolor="FFFFFF">#form.club312check#</td><td bgcolor="FFFFFF">#form.club3pgcheck#</td><td bgcolor="FFFFFF">#form.club3partcheck#</td>
</tr>

</table>

</cfmailpart>

</cfmail>
<cflocation url="/confirm">


Thanks for everyone's posts thus far!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top