Solved

Dynamically created checkboxes

Posted on 2003-11-06
6
249 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 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
Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
iis reverse proxy virtual directory 8 267
DNS, website, godaddy 6 101
Moving web servers into a DMZ? 3 86
Linux Hosting 16 105
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 …
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

739 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