[jQuery] Re: jquery find out which option is selected

2009-06-11 Thread mkmanning

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  wrote:
> THE HTML - A group of radio button
>
>  Milk
>  Butter
>  Cheese
> 
>  Water
>  Beer
>  Wine
>
> THE JQUERY
>
> 
>
> $(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);
>
> });
> });
>
> 
>
>
>
> On Thu, Jun 11, 2009 at 5:36 PM, jjsanders  wrote:
>
> > How can i check in a poll which radio button was selected?


[jQuery] Re: jquery find out which option is selected

2009-06-11 Thread waseem sabjee
THE HTML - A group of radio button

 Milk
 Butter
 Cheese

 Water
 Beer
 Wine

THE JQUERY



$(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);
});

});


On Thu, Jun 11, 2009 at 5:36 PM, jjsanders  wrote:

>
> How can i check in a poll which radio button was selected?