Hi Andy,

My approach with radio buttons:
- Bind a click function to the group
- when clicked, check the value - if it's the one you want, show - otherwise, 
hide

$("[EMAIL PROTECTED]").click(function() {
if(this.value == 'm') {
    $('#manual').show("fast");
}
else {
 $('#manual').hide("fast");
}

-- Josh


    
  ----- Original Message ----- 
  From: Andy Matthews 
  To: [jQuery] 
  Sent: Wednesday, March 21, 2007 9:57 AM
  Subject: [jQuery] toggle a div based on clicking a specific radio button


  I have three radio buttons, each with an id ("p", "s", "m") and a group name 
of "domainlist". I also have a div with an id ("manual") which contains a 
textarea box. I'm styling the div to be hidden by default. What I'd like is 
that when someone clicks the "m" radio button, I'd like to display the manual 
div but if they click any other radio button, I want to hide it (if it's not 
already hidden).

  I know how to access any of the form fields using their ID, but I can never 
remember how to interact with radio buttons or checkboxes. This is what I've 
got so far:

  // it's the third radio button that is "m"
  $([EMAIL PROTECTED]')get[2].toggle(function(){
   $('#manual').slideDown("fast");
  },function(){
   $('#manual').slideUp("fast");
  });

  Here's the code:
  <input type="radio" name="domainlist" value="p" id="p"> <label 
for="domainlist_p">Run primaries</label><br />
  <input type="radio" name="domainlist" value="s" id="s"> <label 
for="domainlist_s">Run secondaries</label><br />
  <input type="radio" name="domainlist" value="m" id="m"> <label 
for="domainlist_m">Run these</label><br />
  <div id="manual">
      <textarea name="manual" rows="6" cols="35"></textarea>
  </div>

  ____________________________________

  Andy Matthews
  Senior Coldfusion Developer

  Office:  877.707.5467 x747
  Direct:  615.627.9747
  Fax:  615.467.6249
  [EMAIL PROTECTED]
  www.dealerskins.com



------------------------------------------------------------------------------


  _______________________________________________
  jQuery mailing list
  [email protected]
  http://jquery.com/discuss/

Attachment: attf350d.bmp
Description: Windows bitmap

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to