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
  • 959,406
  • 173
  • 1,780
  • 1,769
James Stafford
  • 999
  • 1
  • 11
  • 40

7 Answers7

3

Another option...

$('input[name=schoose]:checked').val()
MisterIsaak
  • 3,832
  • 6
  • 34
  • 54
1

Try this

document.getElementsByName('schoose')[1].value;
Sushanth --
  • 54,565
  • 8
  • 62
  • 98
1

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

NullPoiиteя
  • 55,099
  • 22
  • 123
  • 139
avolquez
  • 733
  • 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я
  • 55,099
  • 22
  • 123
  • 139
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
  • 197,815
  • 30
  • 248
  • 265
0
document.getElementsByName('schoose')[1]
Silkster
  • 2,132
  • 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
  • 4,921
  • 4
  • 39
  • 79