Title: Message
Hi,
 
I would be careful trusting that both lists would be the same - imagine if some one blanks out one of the price text boxes - the price list would be n -1. [As CF removes blank list entries]
 
how about explicity naming the price boxes, i.e.
 
<input type="Text" name="price_#productid#" value="#unitprice#" size="5" maxlength="10">
 
then your action cfm could loop through the form to find all the price_x fields and parse the productid out of the field name before doing the updating.
 
i.e.
 
<!--- this is nasty stuff - got to love old evaluate! --->
<cfif isdefined("form.updateprice")>
 <cfset Variables.stPriceUpdates = StructNew()>
 <cfloop index="i" list="#FORM.PRODUCTID#">
  
  <cfset Variables.thisValue = Evaluate("Form.Price_#i#")>
  
  <cfif Len(Trim(Variables.thisValue))>
    <!--- valid, non-blank string --->
   <cfset StructInsert( Variables.stPriceUpdates,"#i#", #Variables.thisValue#)>
  </cfif>
 
 </cfloop>
 
 <cfdump var="#Variables.stPriceUpdates#">
 
</cfif>
 
cheers
 
David
-----Original Message-----
From: Clifton Steve [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 15, 2004 3:03 PM
To: CFAussie Mailing List
Subject: [cfaussie] RE: NEW batch style update request

greg,
 
if both lists have the same number of values, then i would loop over the lists like this:
 
<cfloop index="x" from="1" to="#listlen(form.productid)#" step="1">
 
<CFQUERY NAME="updateprice" DATASOURCE="#prefs.dsn#">
UPDATE     products
SET        unitprice= 
#listgetat(form.price,x)#
WHERE   productid = #listgetat(form.productid,x)#
</CFQUERY>

</cfloop>
 
this is a very simplistic approach, but might get you started.
 
steve
 
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: Tuesday, 15 June 2004 3:15 PM
To: CFAussie Mailing List
Subject: [cfaussie] NEW batch style update request

Hi
 
i thought i would try and outline the action i am trying to create,
 
i am passing 2 "variables.lists" to an "query update" and would like to loop over the values.
The variable lists are:
 
productid=1,2,3,4,5,6,7
 
price=22,44,55,33,55,33
 
 
the update query :
<cfloop index='item' list='#form.productid#' delimiters=','>
<CFQUERY NAME="updateprice" DATASOURCE="#prefs.dsn#">
UPDATE     products
SET        unitprice= #price#
WHERE       (productid = '#item#')
</CFQUERY>
</cfloop>
 
the probelm at hand is how to index loop on both variables and update the table with the correct values.
i am stuck on this one and need some direction if any one has a snipet or a helpful comment .
it will make my day.
greg

----- Original Message -----
Sent: Tuesday, June 15, 2004 2:49 PM
Subject: [cfaussie] Re: batch style update

Hi i am still stuck on updating a list of prices does anyone have any pointers for me..
 
 the form looks like the one below and i would like to update all prices to the new values.
 
code here
 
Form look like this
 
<form action="" method="POST">
<input type="Hidden" name="updateprice" value="updateprice">
<table cellspacing="2" cellpadding="2" border="0">
<tr>
<td>Product Part No Name</td><td>Featured</td><td>Special</td><td>Hide</td><td>Price</td>
</tr>
<cfoutput query="special">
<input type="Hidden" name="productid" value="#productid#">
<tr bgcolor="#IIf(CurrentRow Mod 2, DE('#prefs.rowcolor1#'), DE('#prefs.rowcolor2#'))#">
<td>#productpartno# - #productname#</td>
<td><input type="Checkbox" name="Featured" value="#productid#" <cfif "#Featured#" is "yes">checked</cfif>></td>
<td><input type="Checkbox" name="special" value="#productid#" <cfif "#special#" is "yes">checked</cfif>></td>
<td><input type="Checkbox" name="hiddenprod" value="#productid#" <cfif "#hiddenprod#" is "yes">checked</cfif>></td>
<td><input type="Text" name="price" value="#unitprice#" size="5" maxlength="10"> <cfif "#hiddenprod#" is "yes">checked</cfif></td>
</tr>
</cfoutput>   
</table>
<input type="Submit" name="save" value="save changes">
</form>
   Update action looks like this   <cfif isdefined("form.updateprice")>
<cfloop index='price' list='#form.price#' delimiters=','>
<cfloop index='item' list='#form.productid#' delimiters=','>
<CFQUERY NAME="updateprice" DATASOURCE="#prefs.dsn#">
UPDATE     products
SET        unitprice='#price#'
WHERE       (productid = '#item#')
</CFQUERY>
</cfloop>
</cfloop>
</cfif>
     
Product Part No Name Featured Special Hide Price
H9196DKRW - Tuna Hooks
H540 - Reef Hooks
H542 - Reef Hooks
H4480 - Shark Hooks
H4483 - Shark Hooks
H34007NPSS - Fly Hooks
H7691LS - Trolling Hooks
H7691S - Trolling Hooks
H7732 - Trolling Hooks

----- Original Message -----
Sent: Tuesday, June 15, 2004 12:47 PM
Subject: [cfaussie] batch style update

Hi

I have a batch feature i have developed to update the products table.
at this stage i have the check boxes updating and would now like to add a
text field for price.

the probelm i have is lining up the values so they insert the correct
details.
with the check boxes i have a simple system  re below.

<!--- set featured specials and hidprod to no --->
<CFQUERY NAME="resetfeatured" datasource="#prefs.dsn#" >
UPDATE     products
SET  featured = 0
<cfif isdefined("form.featured")>
where productid NOT IN ('#form.featured#')
</cfif>
</CFQUERY>

<!--- loop over selected fields and update table --->
<cfif isdefined("form.hiddenprod")>
<cfloop index='item' list='#form.hiddenprod#' delimiters=','>
<CFQUERY NAME="updatehiddenprod" DATASOURCE="#prefs.dsn#">
UPDATE     products
SET        hiddenprod=1
WHERE       (productid = '#item#')
</CFQUERY>
</cfloop>
</cfif>

this works perfect for the check box enteries but not for products.

the problem for the products is lining up the values productid with the
values to be updated.

hope all this makes sense....
heres the code if anyone can point me in the right direction would be a
great help!

save the new data
<cfif isdefined("form.updateprice")>
<cfloop index='price' list='#form.price#' delimiters=','>
<cfloop index='item' list='#form.productid#' delimiters=','>
<CFQUERY NAME="updateprice" DATASOURCE="#prefs.dsn#">
UPDATE     products
SET        unitprice='#price#'
WHERE       (productid = '#item#')
</CFQUERY>
</cfloop>
</cfloop>
</cfif>

this is the form that submits the data
<form action="" method="POST">
<input type="Hidden" name="updateprice" value="updateprice">
<table cellspacing="2" cellpadding="2" border="0">
<tr>
<td>Product Part No
Name</td><td>Featured</td><td>Special</td><td>Hide</td><td>Price</td>
</tr>
<cfoutput query="special">
<input type="Hidden" name="productid" value="#productid#">
<tr bgcolor="#IIf(CurrentRow Mod 2, DE('#prefs.rowcolor1#'),
DE('#prefs.rowcolor2#'))#">
<td>#productpartno# - #productname#</td>
<td><input type="Text" name="price" value="#unitprice#" size="5"
maxlength="10"> <cfif "#hiddenprod#" is "yes">checked</cfif></td>
</tr>
</cfoutput>
</table>
<input type="Submit" name="save" value="save changes">
</form>

regards greg


---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/ ---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED] Aussie Macromedia Developers: http://lists.daemon.com.au/ ---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED] Aussie Macromedia Developers: http://lists.daemon.com.au/
---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED] Aussie Macromedia Developers: http://lists.daemon.com.au/
---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED] Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to