What's new

Javascript Array

Status
Not open for further replies.
Miles x

Miles x

Getting There
Grammar Nazi Mr. Nice Guy Tutorial Creator
Messages
1,310
Reaction score
117
Points
235
Sin$
0
Hi there, trying to create a little webpage which will as the user to input 5 numbers, one by one and store them in an array, could someone help me do this?

I haven't used javascript for a while and just want to do something simple but can't seem to find the right answer on Google.
 
Wheen

Wheen

Bytesexual
Retired
Programmer Grammar Nazi Mr. Nice Guy
Messages
6,145
Reaction score
2,342
Points
665
Sin$
0
Code:
var array = [
	document.getElementById('TextField1').value,
	document.getElementById('TextField2').value,	
	document.getElementById('TextField3').value,	
	document.getElementById('TextField4').value,
	document.getElementById('TextField5').value
]

Where each of the strings are the id of the textfields
 
Miles x

Miles x

Getting There
Grammar Nazi Mr. Nice Guy Tutorial Creator
Messages
1,310
Reaction score
117
Points
235
Sin$
0
Code:
var array = [
    document.getElementById('TextField1').value,
    document.getElementById('TextField2').value,   
    document.getElementById('TextField3').value,   
    document.getElementById('TextField4').value,
    document.getElementById('TextField5').value
]

Where each of the strings are the id of the textfields
Thank you! Helps a lot! :smile:
 
Z61

Z61

Some times our saints are sinners
Retired
Programmer Forum Addict Odysseus' Summit
Messages
5,468
Reaction score
3,429
Points
1,042
Sin$
0
OP's problem has been solved.
Locked.
 
Status
Not open for further replies.
Top Bottom
Login
Register