This topic is locked

Interpretation of Javascript code-behind remove button on shopping car

8/17/2009 5:01:37 PM
Shopping Cart Template general questions
J
John Fiore - DFS author

Hello, we have started using the shopping cart template and have found it quite helpful in getting a cart running in minutes!
We are attempting to modify the look of the shopshopping_cart_list.php page and are having difficulty understanding the Javascript code-behind the REMOVE button. Specifically the "input" array (is it?):
/---------------------

<span class=buttonborder><input type=button class="button" value="Delete selected" onclick="

if($('input[@type=checkbox][@checked][@name^=selection]').length && confirm('Do you really want to delete these records?'))

frmAdmin.submit();

return false;"></span>

\---------------------
I attempted to find resources online, but I must not be using the right search key words. Any help is much appreciated.
Thank you in advance!

---John---

J
Jane 8/18/2009

John,
this code checks all selected records on the page and submit form.

Please clarify what you want to achieve and I'll help you.

J
John Fiore - DFS author 8/19/2009

Hi Jane,

Thanks for your reply. I was actually looking for a reference to a web site that explains to better understand -- what appears to be -- a JS array of the variable named "input" and what the $, @ ^ and [] represent in the code below from the shopshopping_cart_list.php page:
if($('input[@type=checkbox][@checked][@name^=selection]').length
But to answer your question...

I want to replace the checkboxes next to each productID in the cart with a button/link so the consumer clicks on each button/link to remove that productID from the cart, instead of selecting the checkbox(es) then clicking on the delete button. For example:
echo "<td align=\"right\"><a href=\"_cart-confirm.php?remove=$ID\"><img name=\"remove\" SRC=\"_images/btn_remove.jpg\" ALT=\"Remove\" BORDER=\"0\">" . "</a></td>";
Thanks in advance for your help.

---John---

John,

this code checks all selected records on the page and submit form.

Please clarify what you want to achieve and I'll help you.

J
Jane 8/20/2009

John,
you can delete each record separately using this code:

<a href="tablename_list.php?remove={$ID_value}"><img name="remove" SRC="_images/btn_remove.jpg" ALT="Remove" BORDER="0"></a>


Then check $_REQUEST["remove"] in the List page: Before process event and remove selected records if needed.