Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

store object in input value

// encoding
let obj = {
  key1: "foo",
  key2: "bar"
};
document.querySelector('body').insertAdjacentHTML('beforeend', `<input name="sample_input" id="input" value=${encodeURIComponent(JSON.stringify(obj))}>`);

// decoding
JSON.parse(decodeURIComponent(document.querySelector('#input').value));
 
PREVIOUS NEXT
Tagged: #store #object #input
ADD COMMENT
Topic
Name
1+8 =