/    Sign up×
Community /Pin to ProfileBookmark

using loops in names

hey guys.

I have several radio buttons per “question” (its a testing program). the number of buttons is anywhere between 2-8 per question. for each question the name of the button is answer[Number HERE]
like so:

answer0 (radio button name)
answer0
answer0
answer0

[New Question]
answer1
answer1
answer1

..and so on.

how can i use a loop, to make sure that each question has a selected answer? btw its all on one form.
what i wanted to do was go document.formname.answer + i + .length
where i is a looping integer.

Any help greatly appreciated.?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@SpectreReturnsJun 17.2005 — document.formname['answer'+i].length

Try that
Copy linkTweet thisAlerts:
@BoooozeauthorJun 17.2005 — Awesome dude. Thanks so much! been trying to figure this out for a while now :rolleyes:
Copy linkTweet thisAlerts:
@SpectreReturnsJun 17.2005 — No problem. Glad I could help.
×

Success!

Help @Booooze 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.20,
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,
)...