/    Sign up×
Community /Pin to ProfileBookmark

How to check radiobutton list values using javascript?

Hi,
I want to check radiobutton list values using javascript.I have 5 list items in radiobutton list.If we check first item that value is true remaining all are false.and second item we select that is only true remaining all are false .I want output like that .Anybody can give good solution to me.i checked already in google there is so many solutions for 2list items only i tried like that.But it is not working.

Thanks & Regards
Hari

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@holyhttpOct 16.2012 — Given all radio buttons in the group share the same name, let's call it myradio. Each radio button is associated with a unique value that identifies the choice your end-user made. Here is the interesting thing: only the value of the selected radio button is sent when the form is submitted to the server. So there is really no need to change the value of the remaining radio buttons.

In terms of usability, changing the values to true or false will not help you identify which one of those radio buttons were selected by the user.

If you just want to use the true or false states in your client-side program, you can just look if

myradio[i].checked is true or false.



For instance if the first radio button is checked then myradio[0].checked evaluates to true

while myradio[1].checked, myradio[2].checked , myradio[3].checked, myradio[4].checked all evalute to false



I hope the approach offered above suits your need.
×

Success!

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