?
Solved

Multiple check box loaders

Posted on 2005-03-14
9
Medium Priority
?
129 Views
Last Modified: 2013-12-24
I have a web page with multiple rows and one checkbox in eachrow and i want to run an update script for each row that is checked. how do i do that??

this is a product review and add page, so i want to add the product details to my main product table if i check it on the web page.

I only know how to do an update for one product not for multple products at the same time which would save me ltos of time!

0
Comment
Question by:finnstone
[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
9 Comments
 
LVL 12

Expert Comment

by:mmc98dl1
ID: 13540554
The way I deal with this is to name the checkboxes like this check_prdId where prd_id = the product id.

<input type="checkbox" name="check_23" value="1"/>

Then at the bottom of the html form I put in a hidden field with all the prdid on this page;

<input type="hidden" name="prdlist" value="23,24,25" />

The action page then loops through prdlist and does an isDefined on check_#i#

<cfloop index="i" list="#form.prdlist#" delimiters="," >
<cfif isDefined("check_#i#")>
<!--- Do database update here --->
</cfif>
</cfloop>
0
 

Author Comment

by:finnstone
ID: 13540642
i like it, close.   this is a repeating region and is dynamic though...

the problem is that my list will be ever evolving so i will not know the numbers in the list. for example, my db may have 300 products in it , or it could have 290 products in it, i would not know at any particular time and cannot hard code the hiden field.

also i have a dynamic value for each check box, but how do i code that value  in the html

name="check_23" ?
0
 

Author Comment

by:finnstone
ID: 13540670
this will prob work for dynamic name,         <input type="checkbox" name="<cfoutput>#newps.productoid#</cfoutput>check" value="checkbox">


but still ,how do i fix the fact that i cannot predefine the list as you did in your example?? i could pull a query to make a list but i do not know how to make a list adn then send that lists into the value attribute of the hidden field, please hlpe with that.

thanks
0
Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 
LVL 12

Expert Comment

by:mmc98dl1
ID: 13540851
So you are running through a wuery to list out the products right?

As you go down through the query you could do

<cfset prodid = ListAppend(prodid,#newps.productoid#,",")> This will then set up a value of prodid with al the ones in the list above, you can then chuck this into the hidden field.
0
 
LVL 12

Accepted Solution

by:
mmc98dl1 earned 2000 total points
ID: 13540863
Form:
<cfoutput>
<form>
<cfset prdlist = "">
<cfloop query="newsps">
<cfset prdlist = ListAppend(prdlist,#productoid#,",")>
 <input type="checkbox" name="#productoid#check" value="checkbox">
</cfloop>
<input type="hidden" name="prdlist" value="#prdlist#" />
</form>
</cfoutput>
action page:

<cfloop index="i" list="#form.prdlist#" delimiters="," >
<cfif isDefined("#i#check")>
<!--- Do database update here --->
</cfif>
</cfloop>
0
 
LVL 17

Expert Comment

by:Tacobell777
ID: 13541252
you can just name all the checkboxes the same and on the action page you will get a list of values, for example if you name all checkboxes test, then #test# would contain a list of ids, i.e. 23,43,2345,233
0
 
LVL 25

Expert Comment

by:James Rodgers
ID: 13544290
0
 
LVL 3

Expert Comment

by:Meps
ID: 13545323
One thing I like to use when dealing with dynamic forms is to have a debugger to help me determine what information is being sent to my action page.  Just replace your action page with this.

Here is an example of a basic debugger.
<body>
<cfloop index="FIELDNAMES" list="#FORM.FIELDNAMES#">
<cfoutput>
#FIELDNAMES# #form["#FIELDNAMES#"]#<BR>
<!--- You can leave off the If Statement if you want --->
<cfif #form["#FIELDNAMES#"]# GTE 1>
GOOD<BR>
<cfelse>
NOT<BR>
</cfif>
</cfoutput>
</cfloop>
</body>

There are multiple ways to go about what you need.  From use the name of the checkbox as your unique product ID, to having them all the same name, and having the value as your unique ID.
0
 

Author Comment

by:finnstone
ID: 13546939
thanks i will test tonight!
0

Featured Post

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

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

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…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

777 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