Note that there are some explanatory texts on larger screens.

plurals
  1. POPlease help me find error in my jquery code?
    primarykey
    data
    text
    <p>i creating a drag&amp;drop cart in virtuemark. but i have a problem in this javascript jquery script and i spent all a day to find error in these codes:</p> <pre><code>function addToCart( jQueryitem ) { var jQuerylist = jQuery( "ul", jQueryhv_cart_items ).length ? jQuery( "ul", jQueryhv_cart_items ) : jQuery( "&lt;ul class='gallery ui-helper-reset'/&gt;" ).appendTo( jQueryhv_cart_items ); //ajax add to cart var hvvid = jQueryitem.attr("id"); var hvvcatid = jQueryitem.attr("catid"); jQuery.get("index.php?quantity[]=1&amp;addtocart=Thêm vào giỏ hàng&amp;option=com_virtuemart&amp;view=cart&amp;task=add&amp;virtuemart_product_id[]="+hvvid+"&amp;virtuemart_category_id[]="+hvvcatid,function(data,status){ //alert("Data: " + data + "\nStatus: " + status); }); //@hoangvi: find product has the same id with hvvid //if founded update product quantity //otherwise add product to cart var total_li = jQuerylist.find("li").length; for (var i=0; i&lt;total_li; ++i) { var current_li = jQuerylist.find("li")[i]; //alert(jQuery('&lt;div/&gt;').append(current_li.clone()).html()); var li_hidden = current_li.find("span.hv_hidden"); //alert(jQuery('&lt;div/&gt;').append(li_hidden.clone()).html()); var id = li_hidden.attr("id"); //alert(id); if (id == hvvid) { //founded var quantity = li_hidden.attr('quantity'); //alert(quantity); quantity = quantity+1; li_hidden.attr('quantity',quantity); return; } } //add product to cart var jQueryitem2 = jQuery('&lt;li class="ui-widget-content ui-corner-tr"&gt;&lt;/li&gt;'); var jQueryitem_img = jQuery("&lt;div /&gt;").append(jQueryitem.find( 'img' ).clone()).html(); jQueryitem2.append( jQueryitem_img ).append('&lt;span&gt;SL: 1&lt;/span&gt; ' ) .append('&lt;span class="hv_hidden" id="' + hvvid + '" quantity="1"&gt; &lt;/span&gt; '); jQueryitem2.appendTo( jQuerylist ).fadeIn(function() { jQueryitem2 .animate({ width: "48px" }) .find( "img" ) .animate({ height: "36px" }); }); jQueryitem2.append() //}); } </code></pre> <p>i think this problem in these codes:</p> <pre><code> //@hoangvi: find product has the same id with hvvid //if founded update product quantity //otherwise add product to cart var total_li = jQuerylist.find("li").length; for (var i=0; i&lt;total_li; ++i) { var current_li = jQuerylist.find("li")[i]; //alert(jQuery('&lt;div/&gt;').append(current_li.clone()).html()); var li_hidden = current_li.find("span.hv_hidden"); //alert(jQuery('&lt;div/&gt;').append(li_hidden.clone()).html()); var id = li_hidden.attr("id"); //alert(id); if (id == hvvid) { //founded var quantity = li_hidden.attr('quantity'); //alert(quantity); quantity = quantity+1; li_hidden.attr('quantity',quantity); return; } } </code></pre> <p>because it work normally when i delete the above code(but cannot update product quantity when i add two product has same id). i think this is a syntax error because it make jquery cant work normally. the html code like this:</p> <pre><code>&lt;ul class="gallery ui-helper-reset"&gt; &lt;li class="ui-widget-content ui-corner-tr" style="width: 48px;"&gt;&lt;img src="/chovietnam.com/images/stories/virtuemart/product/resized/vantech-vt-3500i_90x90.jpg" alt="vantech-vt-3500i" class="featuredProductImage" border="0" style="height: 36px;"&gt;&lt;span&gt;SL: 1&lt;/span&gt; &lt;span class="hv_hidden" id="24" quantity="1"&gt; &lt;/span&gt; &lt;/li&gt;&lt;li class="ui-widget-content ui-corner-tr" style="width: 48px;"&gt;&lt;img src="/chovietnam.com/images/stories/virtuemart/product/resized/lenovo-g460small_90x90.jpg" alt="lenovo-g460small" class="featuredProductImage" border="0" style="height: 36px;"&gt;&lt;span&gt;SL: 1&lt;/span&gt; &lt;span class="hv_hidden" id="21" quantity="1"&gt; &lt;/span&gt; &lt;/li&gt;&lt;li class="ui-widget-content ui-corner-tr" style="width: 48px;"&gt;&lt;img src="/chovietnam.com/images/stories/virtuemart/product/resized/designer-handbag-223093101833428290_90x90.jpg" alt="designer-handbag-223093101833428290" class="featuredProductImage" border="0" style="height: 36px;"&gt;&lt;span&gt;SL: 1&lt;/span&gt; &lt;span class="hv_hidden" id="19" quantity="1"&gt; &lt;/span&gt; &lt;/li&gt;&lt;/ul&gt; </code></pre> <p>anyone can help me solve this problem, thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload