Finally got it to work. My difficulty was occurring when declaring a div within a table. Somehow it was closing the div (</div>) artificially which returned no radio class.
I appreciate your help on this. On Mar 4, 12:08 pm, mkmanning <michaell...@gmail.com> wrote: > Given this markup: > <div id="itemList"> > <input type="radio" name="test" value="foo" /> > <input type="radio" name="test" value="bar" checked="checked" /> > <input type="radio" name="test" value="boo" /> > </div> > <span id="testbutton">Test</span> > > Then this script run ondomready will log "bar": > console.log( $('#itemList input:radio:checked').val() ); > > and this will let you check a different radio and test that you can > see its value: > $('#testbutton').click(function(){ > console.log( $('#itemList input:radio:checked').val() ); > > }); > > On Mar 4, 7:03 am, ricardobeat <ricardob...@gmail.com> wrote: > > > The CF loop doesn't matter, what the HTML output is like? In XHTML the > > input element is self-closing (/>) and the checked attribute should be > > checked="checked". > > > If nothing else is wrong, both ways work fine:http://jsbin.com/avodi/ > > > On Mar 4, 9:49 am, Swatchdog <scott.swatch...@gmail.com> wrote: > > > > Thanks for your attention. I am a new member, so they must be delaying > > > me an entire day... > > > > Just trying to understand this better, so here is where I am on this: > > > > This works: (It returns the ItemID which is '111') > > > $(document).ready(function() { > > > console.log($("input[name='ItemID']:checked").val()) > > > > }); > > > > This does not work: (It returns "Undefined") > > > $(document).ready(function() { > > > console.log($('#ItemList input:radio:checked').val()) > > > > }); > > > > Here is the <div> (with the coldfusion loop) > > > > <div id="ItemList"> > > > <cfoutput query="cfqryItemList"> > > > <input type="radio" name="ItemID" value="#ItemID#" <cfif > > > FORM.ItemID > > > EQ #ItemID#> checked</cfif>> > > > </cfoutput> > > > </div> > > > > It is the only Id="ItemList" on the page. > > > > On Mar 3, 9:01 pm, mkmanning <michaell...@gmail.com> wrote: > > > > > The problem with an id on the input is there are several inputs, and > > > > you need to find which one is checked. > > > > If you're containing div is #itemList then this should work if you > > > > want the value: > > > > > $('#itemList input:radio:checked').val() > > > > > On Mar 3, 5:37 pm, James <james.gp....@gmail.com> wrote: > > > > > > Oops, I forgot the id in the input: > > > > > <input type="radio" id="ItemList" name="myRadio" value="blah" /> > > > > > > Oh, and make sure you only have one id="ItemList" in your HTML. You > > > > > cannot have several elements with the same id. > > > > > > On Mar 3, 3:36 pm, James <james.gp....@gmail.com> wrote: > > > > > > > The code looks fine. Do you have a value defined on your radio > > > > > > input? > > > > > > > Suppose your input is: > > > > > > <input type="radio" name="myRadio" value="blah" /> > > > > > > > and your code is: > > > > > > $("#ItemList:checked").val() // returns 'blah' if radio is checked > > > > > > $("#ItemList").is(":checked"); // returns true if radio is checked > > > > > > > On Mar 3, 3:56 am, Swatchdog <scott.swatch...@gmail.com> wrote: > > > > > > > > I have an order edit form that is fed from Coldfusion/SQL that > > > > > > > shows a > > > > > > > radio list of possible product selections. If the customer is > > > > > > > editing > > > > > > > an order that has already been submitted, one of the products in > > > > > > > the > > > > > > > radio list is selected. If it is a new order, none is selected. > > > > > > > > Upon load, I need to determine which one, if any, is selected so > > > > > > > that > > > > > > > I can turn manipulate other elements on the page. > > > > > > > The div for the radio input list is id = ItemList. > > > > > > > > This below does not work, it returns "Undefined" in the alert box. > > > > > > > > $(document).ready(function() { > > > > > > > alert($("#ItemList:checked").val()); > > > > > > > > }); > > > > > > > > Can someone throw this jPup a bone? > > > > > > > > Thanks > > > > > > > SWimmer