Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to create an object that stores personal data in javascript

<html>
  <body>
    <input id="name" value="Jenna" />
    <input id="address" value="840 9STREET" />
    <input id="postalcode" value="T2P 2T4" />
    <input id="phone" value="111-111-1111" />
    <input id="email" value="Renee@gmail.com" />
    <button id="clickMe">click me</button>
  </body>  
  <script>
    var objectarray = [];
    var button = document.getElementById("clickMe");

    function addToArray() {
      var customerobject = {};
      customerobject.name = document.getElementById("name").value;
      customerobject.address = document.getElementById("address").value;
      customerobject.postalcode = document.getElementById("postalcode").value;
      customerobject.phone = document.getElementById("phone").value;
      customerobject.email = document.getElementById("email").value;
      objectarray.push(customerobject);
      console.log(objectarray);
    }
    button.addEventListener("click", addToArray);
  </script>
</html>
Comment

PREVIOUS NEXT
Code Example
Javascript :: complicated reduce 
Javascript :: function directory javascript 
Javascript :: reverse linklist in javascript 
Javascript :: convert text file to string javascript 
Javascript :: angular interpolation check if value is null 
Javascript :: get index from for in loop javascript 
Javascript :: Form Data error (unable to decode value) characters specials 
Javascript :: acc&egrave;der data-id javascript 
Javascript :: js dom after selectors 
Javascript :: AssertionError [ERR_ASSERTION]: Expected values to be loosely deep-equal: 
Javascript :: pass data from popup js 
Javascript :: nodejs post req accept form data 
Javascript :: automatice color change 
Javascript :: vercel route all pages to a file 
Javascript :: id always returing null angular 
Javascript :: multiplicar celulas js 
Javascript :: react weather app 
Javascript :: Paginate array in JavaScript 
Javascript :: convert fetch in axios 
Javascript :: Log Time from Date 
Javascript :: send offer webrtc 
Javascript :: stiches js keyframes 
Javascript :: easyui treegrid check if row exists 
Javascript :: get data from mulitple query parameters react 
Javascript :: CalendarTriggerBuilder 
Javascript :: how to bind multiple value in javascript 
Javascript :: angular view not changing on model 
Javascript :: mutiple if in express handlebars 
Javascript :: get a list of field name from object javascript 
Javascript :: I want to enable textbox when checkbox is checked in jquery or javascript 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =