[Proto-Scripty] Re: Prototype Radio Box Question
That’s the only way I’ve been able to make it work too, but then it leaves me the problem of unselecting the radio boxes manually, a task made harder because it’s no longer an array. The only way I’ve been able to make this work the way I wanted was to use an old style onclick event which doesn’t somehow seem right anymore! I suppose another way might be to monitor the whole form for a change and pick it up that way. Thanks for the help though. Simon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Prototype Radio Box Question
I didn’t dismiss what you said, but isn’t the problem with that pattern that if I have other radio button sets on the same page it’s going to pull those back at the same time? And that means I'm going to have to look at the name of each item and decide if it’s part of this set of radio buttons or another set of radio buttons? The way I see it if I want separately selectable items, I'd be using Check Boxes. The fact that I'm using a Radio buttons is that I want them to operate as a group and I want to process them as an array. In standard onclick processing, you add an onclick to each type=”radio” and in the function run through the array looking for the selected item, and return the value. What I want to avoid doing if possible is avoid writing code that is dependent upon knowing the names used in form since I want to reuse the code as needed. It seems such as obvious thing to do I’m convinced I’m going about it the wrong way! On Mar 30, 2:23 pm, Walter Lee Davis wa...@wdstudio.com wrote: It's a prototype enumerable if you follow the pattern I put forward -- much better than a vanilla array! $('parentElement').select('input[type=checkbox]').each(function(elm){ elm.checked = false; if (foo == bar) elm.checked = 'checked'; }); Walter On Mar 30, 2009, at 9:17 AM, simon.murgatr...@googlemail.com wrote: That’s the only way I’ve been able to make it work too, but then it leaves me the problem of unselecting the radio boxes manually, a task made harder because it’s no longer an array. The only way I’ve been able to make this work the way I wanted was to use an old style onclick event which doesn’t somehow seem right anymore! I suppose another way might be to monitor the whole form for a change and pick it up that way. Thanks for the help though. Simon- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Prototype Radio Box Question
Thats an idea - use a class as the selector. Maybe I can get that working generically, I will give it a try. On Mar 30, 2:34 pm, Chris Sansom ch...@highway57.co.uk wrote: At 04:20 -0700 30/3/09, simon.murgatr...@googlemail.com wrote: The problem is it only registers the call back on the first of the radio boxes. If I change the id on each input statement so each uses a differenet name, I can register three callbacks. But I want the radio boxes to operate as a set, with only a single possible value. I suspect I am going about this in the wrong way. What is the correct way to do this so that I get told as the user selects a different option? I've never used Form.Element.EventObserver, but I can tell you straight away what's wrong here: although your radios can (and indeed should) have the same /name/ to operate as a set in the form data, they /must/ have separate IDs in the HTML - the page won't validate if they have the same id (no two elements can share an id). They can, however, share the same class, so I suggest doing something like this: input type=radio id=rbEncAll class=rbEncryption name=rbEncryption value=All Allbr/ input type=radio id=rbEncYes class=rbEncryption name=rbEncryption value=YesEncryptedbr/ input type=radio id=rbEncNo class=rbEncryption name=rbEncryption value=NoUnencryptedbr/ But having, as I say, not used this call, I'm not sure how you register the callback. Someone else will have to advise on the detail, but you might be able to do something with: $$('input.rbEncryption').each (function... -- Cheers... Chris Highway 57 Web Development --http://highway57.co.uk/ Everything Is More Difficult Than It Appears -- Adam C Engst --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Prototype Radio Box Question
Ah, I didnt get the relevenace of the span. Yes, I can do that, easily. Thanks everyone of the excellent help. On Mar 30, 3:14 pm, Walter Lee Davis wa...@wdstudio.com wrote: It's all down to the parent Element you choose to wrap these form elements with. It doesn't have to be a span as I had it, you could just give the enclosing paragraph or LI an id and away you go. What you could not do -- what you are correct to assume here -- is use this vague syntax with the form as the parent: $('theFormId').select('input[type=checkbox]') will indeed return ALL the checkboxen in your form. $('theFieldsetId')... $('theListItemId')... $(''theParagraphId')... $('theLabelId')... (this one is even semantically correct!) Any of these will work, adapted to the structure of your form. Walter On Mar 30, 2009, at 9:57 AM, simon.murgatr...@googlemail.com wrote: I didn’t dismiss what you said, but isn’t the problem with that pattern that if I have other radio button sets on the same page it’s going to pull those back at the same time? And that means I'm going to have to look at the name of each item and decide if it’s part of this set of radio buttons or another set of radio buttons?- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---