简体   繁体   中英

javascript get value of radio button not selected

Perhaps a stupid question, perhaps because im a javascript rookie but lets say I have multiple groups of radio buttons with 2 or 3 radio buttons per group.

I can easily get rad1(if selected) by

if (radios[i].checked) {
            myradiovalue=radios[i].value
}

But now how will I get value of rad2 which is not clicked

if (!radios[i].checked) {
    myradiovalue=radios[i].value
}

Determine if the radio button's checked attribute is false and then set the value

if (radios[i].checked == false) {
    myradiovalue = radios[i].value
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM