The @ before name has been deprecated as of jQuery 1.2

A shortcut for getting (or setting) a form value is $(this).val();

You can use .serialize() to get the values of a form in toto, or for
specific form fields:

//to get checked values from both groups (assuming they're in a form)
$("form").serialize()

//specific radio onchange -- logs "group1=Butter" e.g.
$(':radio').change(function(){
        console.log( $(this).serialize() );
});

//specific radio onchange -- simple approach
$(':radio').change(function(){
        console.log( this.name );
        console.log( this.value )
});

Hope that gives you some direction

On Jun 11, 8:46 am, waseem sabjee <waseemsab...@gmail.com> wrote:
> THE HTML - A group of radio button
>
> <input type="radio" name="group1" value="Milk" checked="checked"> Milk<br>
> <input type="radio" name="group1" value="Butter" checked> Butter<br>
> <input type="radio" name="group1" value="Cheese"> Cheese
> <hr>
> <input type="radio" name="group2" value="Water"> Water<br>
> <input type="radio" name="group2" value="Beer" checked="checked"> Beer<br>
> <input type="radio" name="group2" value="Wine" checked> Wine<br>
>
> THE JQUERY
>
> <scrpt type="text/javascript">
>
> $(function() { // wait for DOM to fully load
>
> var groupone = $("inp...@name='group1']");
> var grouptwo = $("inp...@name='group2']");
>
> groupone.change(function() {
>  var myvalue = $(this).attr("value");
> alert(myvalue);
>
> });
>
> grouptwo.change(function() {
>  var myvalue = $(this).attr("value");
> alert(myvalue);
>
> });
> });
>
> </script>
>
>
>
> On Thu, Jun 11, 2009 at 5:36 PM, jjsanders <jigalroe...@gmail.com> wrote:
>
> > How can i check in a poll which radio button was selected?

Reply via email to