I have an html like below
HTML:
<INPUT TYPE=CHECKBOX NAME="clcik" onClick="add('1234','blah')" />
<input type="hidden" id="project" value="" />
JS:
function add(obj1 , obj2){
var jsonArray = [];
var jsonObj = { product_id : obj1 , name : obj2 };
jsonArray.push(jsonObj);
var field = document.getElementById('project');
field.setAttribute('value', JSON.stringify(jsonArray));
alert(field.getAttribute('value'));
}
I am trying to set first and retrieve again to check but nothing is happening..I can't understand where I am wrong...?