|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Updating multiple files with one click
Hello everyone:
I am designing a web photo album where users can upload and see their pictures. Each thumbnail picture will have a checkbok and there will be a button (delete and email). I want the application to delete or email all the selected pictures with a single button click. Does anybody know how to handle this? I know how to delete one picture at a time(e.g. delete.cfm?photoID=#thisID#); but not multiple pictures at once. Thanks, machito |
|
#2
|
|||
|
|||
|
Give each checkbox a unique value (the image name or image path probably). When you submit the form, all of the values that were checked should post to the action page as a comma-delimited list. Loop over that list and for each image do whatever you want.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
Hello Kiteless:
The problem is I am looping through the query RecordCount. Do I have to assign a name for each file's checkbox?. e.g. <cfoutput query="getImages"> <img src = "#myDir##getImages.ImageName#"> <input type="checkbox" value="#imageID#"> </cfoutput> I don't know in advance the number of images in the database. Thus, I cannot predict the number of checkboxes needed. Thanks, machito |
|
#4
|
|||
|
|||
|
<cfoutput query="getImages">
<img src = "#myDir##getImages.ImageName#"> <input type="checkbox" name="imageChooser" value="#imageID#"> </cfoutput> You don't need to predict how many checkboxes you need...they all must have the same name, only the values are different. |
|
#5
|
||||
|
||||
|
i belive i can answer your question, when i was making my shopping cart i had a similar problem because i wanted people to be able to edit their contents from the view cart level and thats a bit complicated to do. so here is my explenation in short...
ok this is a sloppy version of how i would do it. This is for your display page: <input size="1" type="hidden" name="numberofforms" value="<cfoutput>#getImages.recordcount#</cfoutput>"> <cfset formnumber = 1> <cfoutput query="getImages"> <input size="1" type="hidden" name="ID#formnumber#" value="#ID#"> <img src = "#myDir##getImages.ImageName#"> <input type="checkbox" name="imageChooser#formnumber#" value="1"> <cfset formnumber = #formnumber# + 1> </cfoutput> This is for your action page: (example is if you want to delete images from a database) <cfloop index="loopcount" from="1" to="#FORM.numberofforms#"> <cfset variables.imageChooser="form.imageChooser#Evaluate(LoopCount)#"> <cfset variables.imageChooser="#Evaluate(variables.imageChooser)#"> <cfset variables.ID="form.ID#Evaluate(LoopCount)#"> <cfset variables.ID="#Evaluate(variables.ID)#"> <cfquery name="picturedelete" datasource="#datasourcename#" blockfactor="100"> DELETE FROM getImages WHERE ID = #variables.ID# </cfquery> </cfloop> now there may be better ways to do it or even ways to better that code but i found thats the easiest way to do it. let me know if it works |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Updating multiple files with one click |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|