1.11M Members

Whats goes wrong with this code ???

 
0
 

It show error in the dreamweaver

$('#left_bar .cart-info').append('<div>'+localStorage["myid"] = document.getElementById("myid").value =parseInt(localStorage["myid"] || "0", 10) + 1;+'<input id="myid" type="text" name="itemquantity[]" value="1"/></div>');

 
0
 

you misssed sigle quotation mark where i showed BOLD letters in your code (at + sign before input tag started at the end)

$('#left_bar .cart-info').append('<div>'+localStorage["myid"] = document.getElementById("myid").value =parseInt(localStorage["myid"] || "0", 10) + 1;'+'<input id="myid" type="text" name="itemquantity[]" value="1"/></div>');

let me know the status after updating the code

 
0
 

that won't fix the issue as there is a semi colon, also the + with the single quote on the right is fine.

Try this. Also think about readability, if it's hard to read, it's hard to understand.

document.getElementById("myid").value = (parseInt(localStorage["myid"] || "0", 10) + 1);

localStorage["myid"] = document.getElementById("myid").value;

$('#left_bar .cart-info').append('<div>' + localStorage["myid"] + '<input id="myid" type="text" name="itemquantity[]" value="1"/></div>');
You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article