Solved

Dynamically created checkboxes

Posted on 2003-11-06
6
246 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
6 Comments
 
LVL 2

Accepted Solution

by:
jonnygo55 earned 200 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
Network it in WD Red

There's an industry-leading WD Red drive for every compatible NAS system to help fulfill your data storage needs. With drives up to 8TB, WD Red offers a wide array of solutions for customers looking to build the biggest, best-performing NAS storage solution.  

 
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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

948 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now