Changing the key value pair based on users input via JSON - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Form Event

Description

Changing the key value pair based on users input via JSON

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
function Run() {/*from  ww  w  .j a v a  2s  .  com*/
    var x = document.getElementById("fruits");
    var data = {
        "fruits": x.value
    };
    console.log(data.fruits);
}

      </script> 
   </head> 
   <body> 
      <input id="fruits"> 
      <button onclick="Run()">Run</button>  
   </body>
</html>

Related Tutorials