Also, Daemach, you're absolutely right 'input:radio:checked' works great. I just tested it. I learn something new every day! :o)

I combined that with the xpath selector:

$("input:radio:[EMAIL PROTECTED]");

... and it's working just fine! Thanks so much for all your help!! :o)

Cheers,
Chris

Daemach wrote:
Yeah that should work ;)

And you're right - it should be input:checked though :radio:checked might
work as well.  If not, input:radio:checked should do it.  I need to build a
generic text page to test selectors on :) I have this page bookmarked: http://docs.jquery.com/Selectors
I'm a relative noob in terms of jQuery, but my understanding is that
siblings means they are on the same level of the DOM tree - right next to
each other with a common parent might be another way to think about it.  If
you had a td with a select and 2 radios, td would be the parent of the form
fields, the form fields would be children of the td and the form fields
would be siblings to each other.  The benefit to this (I think) is that
instead of searching the entire document and trying to match a string you're
just traversing the DOM inside of the tag's parent element.  If a true
selector/DOM guru could affirm or deny this it would be great!

A great way to do testing with your own page is to do the selectors right in
the firebug console.  If it returns an array of elements you can mouse over
them and FF will highlight the element in the dom so you can verify that it
got the right one.  An empty array means it didn't match anything.



Christopher Jordan wrote:
Doh! I meant $("radio:[EMAIL PROTECTED]" + id + "]") oops.

But, I'm still not sure that 'radio:checked' works. I think I have to use input:checked. I thought about the siblings thing too, but I wasn't sure of the exact relationship between these elements. I'm pretty sure there isn't a parent child relationship between them. :o(

Chris


Daemach wrote:
I understand, but in your radio selector you're using [EMAIL PROTECTED]  which
means
"begins with an underscore"  In this case I think you want [EMAIL PROTECTED] 
which
means "contains an underscore".

Another option might be $(this).siblings(":radio:checked") (UNTESTED!),
this
being the select and with the caveat that each select/radio set should be
descendants of another tag such as a div or td to avoid grabbing all of
the
radio buttons...


Christopher Jordan wrote:
The IDs are differnent. That selector I'm using says find me a radio button that has an attribute "id" which *ends with* in this case a number. The IDs themselves are like this:

<input id="UniqueRadio_1".../>
<input id="OtherUniqueRadio_1.../>

The important thing to me is to get the radio buttons that have the right ID 'index' for lack of a better term. I've got a select box named (cleverly) "select_1". All IDs with an "_1" belong to select_1. See?

Chris

ps. still haven't tried your suggestion. Just saw this post and thought I'd respond real quick. :o)


Daemach wrote:
Hmm - that does bring up a point tho...  aren't ID's supposed to be
unique
even in checkboxes?  May need to use the name attribute instead...



Daemach wrote:
I usually use filter with a selector, but a function should work.  Can
you
not do the following instead tho?

$("radio:[EMAIL PROTECTED]" + id + "]")



Christopher Jordan wrote:
Hi folks,

I've tried to use the filter function in the past, but have never
been successful. Usually, I just figure out another better way to do what I wanted (meaning that filter was probably the wrong choice to begin with), but now I've got a case where I think filter would work fine, but I'm still struggling with a couple of things.

1. do I need to use filter(expression) or filter(filter)?

2. what should my expression or filter look like?

Okay, so here's the situation I find myself in:

I've got a page with several select boxes and there are two radio buttons associated with each one. I need to gather all the select boxes and then for each one I want to select the associated radio button which is checked. I could just get both of the associated radio buttons,
but
I figure that a filter should be able to weed out the ones that are not checked. Right?

Here's what I've got so far:

$("select").each(function(){
    var $thisElement = $(this)[0];
    var id = $.ListLast($thisElement, "_");
// for each select element get the corresponding checked sortdirection radio button
    $("[EMAIL PROTECTED]" + id + "]").filter(function(){
        // I'm just not sure what to put here... maybe something
like:
        $(this).attr("checked");
    });
});

As you can see I'm leaning toward the idea that I think I need a filter(filter) instead of a filter(expression). I'm just not sure what my filter or expression should be or even which one is indeed right.

I would appreciate any help I could get.

Thanks,
Chris

--
http://www.cjordan.us


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


--
http://www.cjordan.us


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


--
http://www.cjordan.us


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/




--
http://www.cjordan.us

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to