/    Sign up×
Community /Pin to ProfileBookmark

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>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@kromolSep 26.2012 — [CODE]number.push[B]([/B]document.getElementById("input").value[B])[/B];[/CODE]
Copy linkTweet thisAlerts:
@dillyw82authorSep 26.2012 — Thanks for your reply
×

Success!

Help @dillyw82 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...