On Tue, 2008-01-29 at 19:58 -0800, biodesign wrote: > Actually you have to use following: > > var var_name = $("[EMAIL PROTECTED]:checked").val();
As of jQuery 1.2, the '@' is no longer necessary to match attributes; see: > > > On Jan 23, 11:35 am, Timothee Groleau <[EMAIL PROTECTED]> > wrote: > > Hi Matt, > > > > On Wed, 2008-01-23 at 03:22 -0600, Matt Quackenbush wrote: > > > Hello, > > > > > I am using the following to grab the value of a radio button: > > > > > str = $("input[name='addType']").val(); > > > > .val() returns the value of the first match element and your query > > matches both radio buttons. If you want to target only the checked one, > > try: > > > > str = $("input[name=addType]:checked").val(); > > > > hth, > > Tim. > > > > > > > > > The XHTML for the radio button is as follows: > > > > > <label for="add-type-1"><input type="radio" name="addType" > > > id="add-type-1" value="prem" /> Premium</label> > > > <label for="add-type-2"><input type="radio" name="addType" > > > id="add-type-2" value="std" checked="checked" /> Standard</label> > > > > > Even though the second radio button is set with the "checked" > > > attribute, the jQuery snippet above always returns the value of the > > > first radio button. I am obviously doing something wrong (again), but > > > cannot seem to pinpoint the error of my ways. > > > > > As always, thanks in advance for your assistance. > > > > > Matt >