|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
undefined
Hi Folks I have the following code to change the quantity in an array that list all the items selected in a shopping cart and displayed on an 'ordercontent' page. If i only have one item on the page the code i am using updates the quantity no problem. BUT as soon as i add a second or third item things go wrong. What i need to do is pass the array record id to the update code. The code for the text area named 'quantity' and my submit!!! button is as follows: ---------------------------------- <input name="quantity" type="text" class="smalllight" value="#session.app_shoppingcart.quantity#" size="1"></td> <td width="5%"><input name="btn_change" type="submit" class="smalllight" value="+ -"></td> ---------------------------------- and the code that actually changes the quantity is as follows: ---------------------------------- <!---Change quantity---> <cfif IsDefined("btn_change")> <cfset newitem = 0> <cfloop from="1" to="#arrayLen(session.app_shoppingcart)#" index="i"> <!----<cfif session.app_shoppingcart.recordid EQ #form.recordid#>----> <cfset session.app_shoppingcart.quantity = #form.quantity#> <cfset newitem = 1> </cfloop> </cfif> ------------------------------- I have the line that looks for the record ID commented out at the moment to stop errors. But all i want to do is pass the record id to the code, can someone please help with this cheers and thanks in advance Grabit |
|
#2
|
||||
|
||||
|
What error message are you getting?
Also, you don't need to hash most of that stuff out, especially in the comparisons and the <cfset>'s. |
|
#3
|
|||
|
|||
|
Is session.app_shoppingcart an array?
__________________
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 |
|
#4
|
|||
|
|||
|
updating shopping cart array
undefined
Yep the cart contents are held in an array, when i only have one item in the cart i dont get any problems because there is only 1 record to update so it does it. If there are more than 1 item in the cart i get a recordid not found error so what i need is a way to add a record id to the "+ -" button beside each quantity so that can pass the correct record id with it to the processing script. cheers |
|
#5
|
|||
|
|||
|
Shouldn't you use your index i to adress a field in your array or alternativly loop through the arrayitems directly instead of only looping the value of its length?
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Updating shopping cart array |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|