finnstone
asked on
adding an identifier for a row
http://www.englishtrunkshowco.com/antiques/china/china.cfm
i would like to add feature where people can add an item to a shopping cart, what is the best way to do that on this page and how can i do that??
thanks
i would like to add feature where people can add an item to a shopping cart, what is the best way to do that on this page and how can i do that??
thanks
Another way would be to use one of the many free shopping carts offered on developers exchange on Macromedia.om
ASKER
sorry i am asking from a more simpler approach.
i have a coldfusion cfc that can process adding something to a cart, i am using this for my flash web site. now i am just looking for a way to call this cfc for adding an item from the html version.. for instance, how can i identify the product that is clicked to be added to cart.
i have a coldfusion cfc that can process adding something to a cart, i am using this for my flash web site. now i am just looking for a way to call this cfc for adding an item from the html version.. for instance, how can i identify the product that is clicked to be added to cart.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<a href="actionpage.cfm?produ ctID=#your ProductID# "><img src="yourimage here"></a>
Better than using javascript, as that might be turned of and won't work for screen readers etc.
Or even use a button <input type="submit" name="product_45" value="Add">
And on the action page you loop through the form scope and see if the field start with "product_" if so do a listlast with delimeter "_" to get the product ID..
You might want to ask your question a bit clearer next time so people don't waste time ;-))
Better than using javascript, as that might be turned of and won't work for screen readers etc.
Or even use a button <input type="submit" name="product_45" value="Add">
And on the action page you loop through the form scope and see if the field start with "product_" if so do a listlast with delimeter "_" to get the product ID..
You might want to ask your question a bit clearer next time so people don't waste time ;-))
ASKER
how could i send the product to a javascript function and how can i call a cfc from that javascript function? then how can i reload the current page from the cfc
thanks for the continual support.
thanks for the continual support.
That's a totally different question again.
Why do you want to go via a javascript function exactly?
CFC's are normally not called from javascript functions, although it's possible, I think if we understood why you want to do this we could recommend a better solution.
Why do you want to go via a javascript function exactly?
CFC's are normally not called from javascript functions, although it's possible, I think if we understood why you want to do this we could recommend a better solution.
ASKER
i want to update the cart using the cfc but i want to refresh the page so that the cart table shows that an item has been added.
i suppose i do not need javascript, all i have to do is call the cfc which will then reload the page.
i suppose i do not need javascript, all i have to do is call the cfc which will then reload the page.
Ok,
So lets say your first page has the add to order button. Which runs an ActionPage.
The actionpage would
1. Invoke the cfc using <CFINVOKE or similar
2. Use <CFLOCATION or a javascript redirect to return to the main page.
The main page would probably also call the cfc to determine the quantities ordered for each product.
So lets say your first page has the add to order button. Which runs an ActionPage.
The actionpage would
1. Invoke the cfc using <CFINVOKE or similar
2. Use <CFLOCATION or a javascript redirect to return to the main page.
The main page would probably also call the cfc to determine the quantities ordered for each product.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
taco, thats an awesome idea, thanks
You can also do it without the page refreshing at all, but taco's answer is the simplest.
ASKER
wait if i call the cfc, then wont i then go to the cfc, and then i will have to do a cflocation just to get back to the main page??
can you show me how this would e done
can you show me how this would e done
Page-----------
<cfif isDefined("url.productid") >
call your cfc here
</cfif>
<a href="thissamepage.cfm?pro ductid=44" >add me</a>
<cfif isDefined("url.productid")
call your cfc here
</cfif>
<a href="thissamepage.cfm?pro
Calling a method in a CFC doesn't actually run the page like <CFLOCATION. It just calls the function and returns to the calling page, passing back paramaters if they exist.
Taco's example is correct.
I assume the cfc will return an array or structure of ordered items. So you will need to check this when redisplaying the page to display the current qty in the order.
Taco's example is correct.
I assume the cfc will return an array or structure of ordered items. So you will need to check this when redisplaying the page to display the current qty in the order.
ASKER
i am getting an error message from this line of code - it says expression required
<td width="24%"><div align="center"><input type="button" value="Add to Cart" onclick="antique_lamps.cfm ?addprodId =#PRODUCT. productoid #"></div>< /td>
<td width="24%"><div align="center"><input type="button" value="Add to Cart" onclick="antique_lamps.cfm
Sorry, must have abreviated this.
<td width="24%"><div align="center"><input type="button" value="Add to Cart" onclick="window.location.a ssign('ant ique_lamps .cfm?addpr odId=#PROD UCT.produc toid#');"> </div></td >
<td width="24%"><div align="center"><input type="button" value="Add to Cart" onclick="window.location.a
Easiest way (for you) is to probably use CLIENT variables, if they click an item you just add the item to a list stored in the CLIENT. scope.
You could do something like, and this is the best I could do, if I need to write anymore I might as well write you a whole shopping cart ;-))
<cfif NOT isDefined("client.order")>
<!--- initialize list --->
<cfset client.order = "">
</cfif>
<!--- if we need to add the item to our order and it does not already exist --->
<cfif isDefined("url.addToOrder"
<cfset client.order = listAppend(client.order, url.addToOrder)>
</cfif>
<!--- if we need to remove the item from the order --->
<cfif isDefined("url.removeFromO
<cfset client.order = listDeleteAt(client.order,
</cfif>
<!--- if we need to display the order --->
<cfif isDefined("url.showOrder")
<cfoutput>
#listLen(client.order)# Item(s) ordered:<br>
</cfoutput>
<cfloop index="item" list="#client.order#">
<!--- retrieve the item details here if need be --->
Item number: #listGetAt(client.order, variables.item)#<br>
</cfloop>
</cfif>
Don't forget to enable client variables in your cfapplication.