$(document).ready(function(){ var $checks = $("input[name=myradiobutton]"), $field = $("#txtfld");
$checks.click(function(){ var value = $checks.filter(':checked').attr('value'); $field[ value == "r2" ? "show" : "hide" ](); }); }); The change event works oddly on IE, so this should be a safe approach. I haven't tested the code, it should work. Cheers -- Ariel Flesler http://flesler.blogspot.com/ On 17 jun, 15:29, The Gorf <[EMAIL PROTECTED]> wrote: > Does anyone have any input on this please? It would be very helpful. > I'm still very stuck. > > -Geoff > > On Jun 13, 5:48 pm, The Gorf <[EMAIL PROTECTED]> wrote: > > > > > Greetings all. I am trying to add some jquery code to a few modules I > > am developing in Drupal 5.x. I'm struggling to get up to speed with > > jquery but so far i've been successful in what I have tried to do. > > Until now. If you would like to see the discussion I have already > > started at Drupal it is athttp://drupal.org/node/269197. > > > I have a very basic html page to outline what I am trying to do. A > > version of it is here: > > >http://www.whootis.com/dev/jquery.html > > > I have three radio buttons as part of a group. I want to accomplish 2 > > things: > > 1> When the page loads, the state of the textfield (hidden or shown) > > is determined based on what radio button has been set to be checked > > and the textfield gets set. > > 2> When ever a user selects radio buttons R1 or R3 the textfield > > remains hidden, and when the user clicks on R2 the textfield becomes > > visible. > > > I have stumbled through various examples and gotten it to work > > sometimes, and other times I can't get it to work at all. Can someone > > help me out here with some advice? > > > -Geoff > > > For reference here is the example page: > > > <html> > > <head> > > <script type="text/javascript" src="jquery.js"></script> > > <script type="text/javascript"> > > $(document).ready(function() > > { > > var checkedValue = $ > > ("[EMAIL PROTECTED]'myradiobutton']").val("r2"); > > $(checkedValue).is(':checked') ? $("#txtfld").hide() : $ > > ("#txtfld").show(); > > > $('input').click(function() > > { > > $ > > ("[EMAIL PROTECTED]'myradiobutton']").val("r2").is(':checked') ? $ > > ("#txtfld").show() : $("#txtfld").hide(); > > }); > > }); > > </script> > > </head> > > > <body> > > <form name="myform" action="#"> > > <input type="radio" value="r1" name="myradiobutton" > > checked="true" />1st<br /> > > > <input type="radio" value="r2" name="myradiobutton" />2nd<br / > > > <select id="txtfld"> > > <option>Milk</option> > > <option>Coffee</option> > > <option>Tea</option> > > </select><br /> > > <input type="radio" value="r3" name="myradiobutton" />3rd<br / > > > </form> > > </body> > > </html>- Ocultar texto de la cita - > > - Mostrar texto de la cita -