Search
 
SCRIPT & CODE EXAMPLE
 

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));
Comment

PREVIOUS NEXT
Code Example
Javascript :: @viewchild in angular :use for take any refrerence of element 
Javascript :: jquery if in page 
Javascript :: How to add click event to table row js 
Javascript :: javascript form data 
Javascript :: random math js 
Javascript :: how to upload react js project on server 
Javascript :: como checar valor do input checkbox angular 
Javascript :: js iterating set 
Javascript :: how to pass props to another component 
Javascript :: getdefaultmiddleware redux toolkit deprecated 
Javascript :: axios get array of urls 
Javascript :: javascript catch all click events 
Javascript :: js document on load 
Javascript :: turn off js console 
Javascript :: object loop javascript 
Javascript :: json parse js 
Javascript :: mdn getcurrentposition 
Javascript :: JavaScript if, else, and else if 
Javascript :: decode jwt tokens 
Javascript :: js key event 
Javascript :: ways to open modal in angular 
Javascript :: document get element by id hover 
Javascript :: javascript keylogger 
Javascript :: react native geocoding 
Javascript :: routerlink not working 
Javascript :: Least common multiple from array 
Javascript :: sequelize transaction 
Javascript :: javascript constructor 
Javascript :: random picture position in react 
Javascript :: find the largest array from an array in javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =