/    Sign up×
Community /Pin to ProfileBookmark

cant get the value of textarea using getElementById

hi
i am using document.getElementById(‘trgtLng[1]’).value to get the value of textarea but i am not getting the value of it. the textarea contains UTF-8 string.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@SixteaseOct 29.2007 — Hello to you. I think the problem is in 'trgtLng[1]'. That would be a string and it all seems to me that you're trying to access the first element of array trgtLng. If that's the case, then omit the quotes: document.getElementById(trgtLng[1]).value
Hope I'm not missing something, I'm a JavaScript newbie myself.
Copy linkTweet thisAlerts:
@KorOct 29.2007 — ...or, if it is really a string and your element has indeed an id="trgtLng[1]" you should have not used brackets, as it is not permitted in HTML or XHTML

See also:

http://www.w3.org/TR/html401/types.html#type-id
×

Success!

Help @shashank4878 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.18,
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,
)...