Re: [jQuery] Select _other_ elements (with a specific class) in same tr
Thanks for your thoughts Brian, fortunately the answer from Wycat works perfectly. I wanted to use Radio-buttons at first, but it seems that it is impossible to return a group to having none-selected. Citrus wrote: > > jazzle, > > You're going to have to code your way out of this one. Ultimately, you > need to write an onClick or onChange event that looks at the other > checkboxes to see if they are checked, and determine what to do from > there. > > Here's a thought (off the top, untested): > $('.noneorone:checkbox').bind('click', function(){ > if ( $('.noneorone:checked').length > 1 && !this.checked ) return > false; // returning false prevents the "click" action, which would > stop the checkbox from being checked. > }) > > Maybe radio buttons are a better choice for this? It'll save you some > work. :) > > - Brian > -- View this message in context: http://www.nabble.com/Select-_other_-elements-%28with-a-specific-class%29-in-same-tr-tf2958743.html#a8294688 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Select _other_ elements (with a specific class) in same tr
jazzle, You're going to have to code your way out of this one. Ultimately, you need to write an onClick or onChange event that looks at the other checkboxes to see if they are checked, and determine what to do from there. Here's a thought (off the top, untested): $('.noneorone:checkbox').bind('click', function(){ if ( $('.noneorone:checked').length > 1 && !this.checked ) return false; // returning false prevents the "click" action, which would stop the checkbox from being checked. }) Maybe radio buttons are a better choice for this? It'll save you some work. :) - Brian > That title may not make much sense, so here's the code: > > > class="noneorone" /> > class="noneorone" /> > > > I want to be able to select _none or one_ of the checkboxes (note: not > using > radio-buttons). > So I would like to know how to address the _other_ checkboxes (with the > class noneorone) in the same . > > Do I need some XPath mixed with CSS or what? > > > Thanks in advance for any help. > -- > View this message in context: > http://www.nabble.com/Select-_other_-elements-%28with-a-specific-class%29-in-same-tr-tf2958743.html#a8277172 > Sent from the JQuery mailing list archive at Nabble.com. > > > ___ > jQuery mailing list > discuss@jquery.com > http://jquery.com/discuss/ > ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Select _other_ elements (with a specific class) in same tr
On Jan 11, 2007, at 8:44 AM, Karl Swedberg wrote: Something like this? $('input:checkbox').bind('click', function() { $(this).parents('tr').siblings().find('input.noneorone') }); Ugh. I misread the request. Forget my answer. Use Yehuda's. :) On Jan 11, 2007, at 8:14 AM, jazzle wrote: (sorry for edit) (I meant to add that I don't want to use the ids if possible) That title may not make much sense, so here's the code: class="noneorone" /> class="noneorone" /> class="noneorone" /> I want to be able to select _none or one_ of the checkboxes (note: not using radio-buttons). So I would like to know how to address the _other_ checkboxes (with the class noneorone) in the same . Do I need some XPath mixed with CSS or what? Thanks in advance for any help. -- View this message in context: http://www.nabble.com/Select-_other_- elements-%28with-a-specific-class%29-in-same-tr- tf2958743.html#a8277172 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Select _other_ elements (with a specific class) in same tr
I hope you didn't assume that I hadn't considered that. Adding a 'none' would ruin the GUI design on a few different levels. NB: This is for an admin section I'm creating in a bespoke CMS, so no-script is not an issue. dave.methvin wrote: > > ... > Why not radio buttons? They work that way automatically and continue to > work > if script is turned off. Just add a "None" radio to indicate none of the > others. > ... > -- View this message in context: http://www.nabble.com/Select-_other_-elements-%28with-a-specific-class%29-in-same-tr-tf2958743.html#a823 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Select _other_ elements (with a specific class) in same tr
I was just doing this not a half hour ago: Assuming that "this" is the checkbox you clicked, jQuery(this).parent().siblings().find("input:checkbox").not(this) Worked great for me! I used the following code to achieve the effect I believe you're searching for (radio button-like functionality made out of checkboxes, so you can easily turn go back to none selected): jQuery(document).ready(function() { jQuery("input:checkbox").click(function() { jQuery(this).parent().siblings().find(":checked").not(this).uncheck(); }) }) jQuery.fn.uncheck = function() { this.each(function(){ this.checked = false; }) } On 1/11/07, jazzle <[EMAIL PROTECTED]> wrote: That title may not make much sense, so here's the code: I want to be able to select _none or one_ of the checkboxes (note: not using radio-buttons). So I would like to know how to address the _other_ checkboxes (with the class noneorone) in the same . Do I need some XPath mixed with CSS or what? Thanks in advance for any help. -- View this message in context: http://www.nabble.com/Select-_other_-elements-%28with-a-specific-class%29-in-same-tr-tf2958743.html#a8277172 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- Yehuda Katz Web Developer | Wycats Designs (ph) 718.877.1325 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Select _other_ elements (with a specific class) in same tr
Something like this? $('input:checkbox').bind('click', function() { $(this).parents('tr').siblings().find('input.noneorone') }); --Karl _ Karl Swedberg www.englishrules.com www.learningjquery.com On Jan 11, 2007, at 8:14 AM, jazzle wrote: (sorry for edit) (I meant to add that I don't want to use the ids if possible) That title may not make much sense, so here's the code: class="noneorone" /> class="noneorone" /> class="noneorone" /> I want to be able to select _none or one_ of the checkboxes (note: not using radio-buttons). So I would like to know how to address the _other_ checkboxes (with the class noneorone) in the same . Do I need some XPath mixed with CSS or what? Thanks in advance for any help. -- View this message in context: http://www.nabble.com/Select-_other_- elements-%28with-a-specific-class%29-in-same-tr- tf2958743.html#a8277172 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Select _other_ elements (with a specific class) in same tr
> I want to be able to select _none or one_ of > the checkboxes (note: not using radio-buttons). Why not radio buttons? They work that way automatically and continue to work if script is turned off. Just add a "None" radio to indicate none of the others. > So I would like to know how to address the > _other_ checkboxes (with the class noneorone) > in the same . Something like this should do it: $(".noneorone").bind("change", function(e){ // user was clearing this checkbox if ( !this.checked ) return; // this button is checked, clear all of them and recheck this one $(".noneorone").attr("checked", false); this.checked = true; }); ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] Select _other_ elements (with a specific class) in same tr
That title may not make much sense, so here's the code: I want to be able to select _none or one_ of the checkboxes (note: not using radio-buttons). So I would like to know how to address the _other_ checkboxes (with the class noneorone) in the same . Do I need some XPath mixed with CSS or what? Thanks in advance for any help. -- View this message in context: http://www.nabble.com/Select-_other_-elements-%28with-a-specific-class%29-in-same-tr-tf2958743.html#a8277172 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/