1
<!DOCTYPE html>
<html>

<head>
  <script>
    function loginButtonClick() {
      var Refresh = document.forms.form1.refresh.value;
      alert(Refresh);

      var Area = document.forms.form1.area.value;
      alert(Ticks);
    }
  </script>
</head>

<body>
  <form id="form1">
    Refresh:
    <br>
    <input id="refresh" type="number" name="Refresh" value="">
    <br>
    <br> area:

    <br>
    <input id="area" type="number" name="area1" value="">
    <br>
    <br>

    <input type="submit" value="Submit" onclick="loginButtonClick()">

  </form>
</body>

How can I save the Refresh and Area values to a JSON file as an array with the following format?

 data = '[{"Refresh" : 100, "area": 10}]';
8
  • 6
    What do you mean stored in a JSON file? You want to write to a file? JavaScript is really limited on that front. Look into JSON.stringify() Commented Feb 1, 2016 at 14:18
  • Possible duplicate of Writing a json object to a text file in javascript Commented Feb 1, 2016 at 14:21
  • For one do not use the click event, but use the form's submit event and return false if you do not want to actually submit the form Commented Feb 1, 2016 at 14:22
  • What are you trying to achieve? Why would you want to write that to a file? what should happen with this file? ... Commented Feb 1, 2016 at 14:29
  • Where does this json file live? Commented Feb 1, 2016 at 14:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.