1,105,406 Community Members

Whats goes wrong with this code ???

mehar89
Newbie Poster
4 posts since Feb 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
Unverified Member
 
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>');

Member Avatar
radhakrishna.p
Posting Whiz in Training
281 posts since Nov 2012
Reputation Points: 29 [?]
Q&As Helped to Solve: 64 [?]
Skill Endorsements: 11 [?]
 
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

Member Avatar
stbuchok
Posting Shark
957 posts since May 2011
Reputation Points: 123 [?]
Q&As Helped to Solve: 142 [?]
Skill Endorsements: 2 [?]
 
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 three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article