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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using dynamic check boxes

Status
Not open for further replies.

Leakyradiator

Technical User
Jul 12, 2002
35
0
0
US
I want to present about 15 checkboxes on a form. Each checkbox's name/value comes from a database.

When the form is filled in, and the appropriate checkboxes checked, it is then submitted.

On the action page, how do I determine which checkboxes are checked and get their name/value and insert the results into another table.

Thanks
 
Code:
[b]form code[/b]

<form...>
<cfset namelist="">
<cfoutput query="stuff">
  <cfset namelist=listappend(namelist,[red]CURRENT_NAME[/red])>
  <input type="checkbox" name="#[red]CURRENT_NAME[/red]#" value="#whatever#"> #Whatever#<br>
</cfoutput>
<cfoutput><input type="text" name="namelist" value="#namelist#"></cfoutput>
<input type="submit" name="action" value="Submit">
</form>

It is critical that the hidden field remains outside of the main cfoutput.

This is psuedo-code, you'll have to do a lot of customizing because I didn't know your field names. This question has been asked probably better than 100 times in the last year or so, there's plenty of info on how to do it.

The red CURRENT_NAME is whatever the name of your variable is.

If we had an example of what you were trying to do, there's _probably_ an easier way to do it, but this will work for sure.

action code

Code:
<cfif isDefined("form.action")>
  Here are your values:
  <cfoutput><cfloop list="#namelist#" index="n">
    #n#: #FORM[n]#<br><br>
  </cfloop></cfoutput>
</cfif>

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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top