1

I have

<form name="send">
<input type="radio" name="schoose" value="24">
<input type="radio" name="schoose" value="25">
<input type="radio" name="schoose" value="26">

I am trying to find the value of the selected radio button I thought it was

document.send.schoose.value

apparently I was wrong, can someone clue me in

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
James Stafford
  • 1,034
  • 1
  • 15
  • 41

7 Answers7

3

Another option...

$('input[name=schoose]:checked').val()
MisterIsaak
  • 3,882
  • 6
  • 32
  • 55
1

Try this

document.getElementsByName('schoose')[1].value;
Sushanth --
  • 55,259
  • 9
  • 66
  • 105
1

try the $("input[name='schoose']:checked").val();

NullPoiиteя
  • 56,591
  • 22
  • 125
  • 143
avolquez
  • 753
  • 1
  • 7
  • 20
0

you can do this by

with javascript

  document.getElementsByName('schoose')[1].value;

and with jquery like below

$("[name=schoose]").each(function (i) {
    $(this).click(function () {
        var selection = $(this).val();
        if (selection == 'default') {
            // Do something
        }
        else {
            // Do something else
        }             
    });
});

or

$("input:radio[name=schoose]").click(function() {
    var value = $(this).val();
  //or
  var val = $('input:radio[name=schoose]:checked').val();
});
NullPoiиteя
  • 56,591
  • 22
  • 125
  • 143
0

In plain JavaScript you can get the values of the second radio button with:

document.getElementsByName('schoose')[1].value;

In jQuery:

$('input[name="schoose"]:eq(1)').val();

jsFiddle example

j08691
  • 204,283
  • 31
  • 260
  • 272
0
document.getElementsByName('schoose')[1]
Silkster
  • 2,190
  • 15
  • 28
0

With just javascript:

    var radio=document.getElementsByName('schoose');

    var radioValue="";
    var length=radio.length;

    for(var i=0;i<length;i++)
    {
       if(radio[i].checked==true) radioValue=radio[i].value;
    }
    alert(radioValue);
vusan
  • 5,221
  • 4
  • 46
  • 81