?
Solved

Multiple check box loaders

Posted on 2005-03-14
9
Medium Priority
?
130 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
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
[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

 
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 expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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 …
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses
Course of the Month8 days, 21 hours left to enroll

621 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