/    Sign up×
Community /Pin to ProfileBookmark

Mutiple element id’s

Hey guys,

Just wondering if it is possible to return the value of multiple elements in one command? If that didn’t make sense, which it probably doesn’t because i’m an idiot, here is an example:

Original code is

[CODE]var aText = document.getElementById(‘textarea1’).value;[/CODE]

Which works nicely, but looking to return the value of three –

[CODE]var aText = document.getElementById(‘textarea1’, ‘textarea2’, ‘textarea3’).value;[/CODE]

Which doesn’t work obviously. Just not sure how to do it, heh. Any help would be muchly appreciated! Thanks guys ?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERApr 16.2007 — Have you tried:
[code=php]
var aText = document.getElementById('textarea1').value;
aText += document.getElementById('textarea2').value;
aText += document.getElementById('textarea3').value;
[/code]
Copy linkTweet thisAlerts:
@mrhooApr 16.2007 — var i=0,str='';

while(i< 3){str+= document.getElementById('textarea'+(++i)).value};

alert(str);
×

Success!

Help @rhyspaterson 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.19,
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,
)...