Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Dynamically created checkboxes

Posted on 2003-11-06
6
Medium Priority
?
252 Views
Last Modified: 2013-12-24
I'm creating a web-based program that manages the library (books and videos) for the office I work in and have run into a small problem.

On the checkin page, I have a cfselect box that lists all the students that currently have materials checked out.  When a student's name is selected, the page automatically reloads and shows, in addition to the cfselect box with the student's name, a list of materials that they currently have checked out.  Each item in the list has a checkbox next to it.

I'd like to be able to check the boxes next to each item that the student is returning, so that they can all be checked in in one pass.  The problem I'm having, though, is that I can't figure out how to dynamically assign "values" to the checkboxes so that they can be processed by the scripting on the action page.  Any ideas?

BTW, for the time being, I've implemented a page that allows me to check in materials one item at a time, so it's not like the entire project is going to bomb if I can't get this one feature working...but it would be a much appreciated feature by the members of our office staff.  So any help recieved would be equally appreciated.

--
Dave "LoneWolf" Savitsky
LoneWofl_CSU@hotmail.com
0
Comment
Question by:LoneWolf_CSU
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 2

Accepted Solution

by:
jonnygo55 earned 600 total points
ID: 9696109
shouldnt be too hard...just have to understand what you are currently doing...

sounds like you are already outputting the checked out items...not sure why you cant assign a value to it though...

<cfoutput query="checkedItems">
  <input type="checkbox" name="checkedIn" value="#checkedItems.itemID#" checked>#itemName#<br>
</cfoutput>

something like that should give you a list of all items being checked in...
 
on your processing page you could loop through the checkedIn variable and process however you like

<cfloop list="#checkedIn#" index="thisItem">
    ...do something with each #thisItem#...
</cfloop>
0
 
LVL 14

Expert Comment

by:Renante Entera
ID: 9698049
You can have something like this :

On you checkin page :

<cfquery name="GetNames" datasource="dsn">
SELECT name FROM TableName
</cfquery>

<cfif IsDefined('nameselected')>
<cfquery name="GetMaterials" datasource="dsn">
SELECT name,material FROM TableMaterial
WHERE name = "#nameselected#"
</cfquery>
</cfif>

<form name="form1" action="process.cfm" method="post">
  Select Name of Student :
  <select name="selectedname" onchange="document.location='checkinpage.cfm?nameselected=<cfoutput>#form.selectedname#</cfoutput>'">
  <option></option>
  <cfoutput query="GetNames">
    <option value="#name#">#name#</option>
  </cfoutput>
  </select>
  <cfif IsDefined('nameselected')>
  <cfoutput query="GetMaterials">
    #material# <input type="checkbox" name="checkedIn" value="#material#">
  </cfoutput>
  </cfif>
</form>

Then on your process.cfm, you may now refer to the checkbox values:

<cfif IsDefined('form.checkedIn')>
  <cfloop list="#form.checkedIn#" index="material" delimiters=",">
    <cfoutput>#material#</cfoutput> <!--- You may now refer to this value --->
  </cfloop>
</cfif>

Goodluck!
eNTRANCE2002 :-)
0
 
LVL 17

Expert Comment

by:anandkp
ID: 9699063
the above example shld help u have an idea, on how to proceed.

let us know what ur code looks like !
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 10

Expert Comment

by:substand
ID: 9699341
you should name all the checkboxes the same name and assign valuies as the id like jonnygo55 sugguested.  then, say you name that <input name="boxes"..> then you just need to process in the action page:

<cfif isdefined("form.boxes")>
    <cfloop list="#form.boxes#" index="item">
             perform action on #item#
    </cfloop>
</cfif>
0
 
LVL 25

Expert Comment

by:James Rodgers
ID: 9701253
in this example empstatus is the name of the check box from the form page where the checkboxes were generated dynamically and named empstatus#currentrow# and given a true value as the query was output

recordcount is set in the form page and is the number of records being submitted in the form

this will check to see if the checkbox was checked and enter the necessary info into a database

<cfloop index="idx" from="1" to="#form.RECCOUNT#">
<cfquery name="setEmpStatus" datasource="" password="" username="">
<cfif isdefined('form.empstatus#idx#')>
<cfset EMPID =  #evaluate('form.empid#idx#')#>
<cfset TRN =  #evaluate('form.empStatus#idx#')#>
INSERT INTO TRNG_EXEMPTION_LIST VALUES ('#EMPID#' , '#TRN#');    
</cfif>
</cfquery>
</cfloop>
0
 

Author Comment

by:LoneWolf_CSU
ID: 9741714
Thanks, all for your help.  I can't believe how easy the solution really was...dunno why it never crossed my mind.

I never did get the automatic refresh working properly...I'm going to continue to work on it, but for the time being I just put a secondary page in there.

Thanks again.

--
Dave "LoneWolf" Savitsky
LoneWolf_CSU@hotmail.com
0

Featured Post

Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question