www.webdeveloper.com
Results 1 to 3 of 3

Thread: Push from user input to array

Hybrid View

  1. #1
    Join Date
    Sep 2012
    Posts
    6

    Push from user input to array

    Hi im trying to teach myself js but im haveing trouble with getting the number to push from user input form to the array any suggestion would be much appreciated thanks

    <html>
    <body>
    <form>
    <input id="input" type=text>
    <input type=button onclick="myFunction()" value="Add Number"/>
    </form>


    <script>
    var number=["1"]

    function myFunction()
    {
    var x=document.getElementById("box");
    number.push=document.getElementById("input").value
    x.innerHTML=number.join('<br/>');

    }
    </script>
    <div id="box"; style="border:1px solid black;width:150px;height:150px;overflow:auto">
    </div>
    </body>
    </html>

  2. #2
    Join Date
    Jul 2011
    Posts
    131
    Code:
    number.push(document.getElementById("input").value);

  3. #3
    Join Date
    Sep 2012
    Posts
    6

    Thanks

    Thanks for your reply

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles