SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2001
    Location
    C'Ville, VA
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    display: show | hide

    Can someone help me with the following script? It currently works in IE, but I am unable to get it to work in NN or Mozilla browsers. I realize that the reference has to change from 'style' to 'layers', but I'm not exactly sure how to accomplish this.

    Here's the JS:

    Code:
     
    function ShowHide() {
    var TheForm = document.forms[0];
     
    if (TheForm.Q14[6].checked == true ) 
    { //Display the DIV.
    OtherEmp.style.display = 'block';
    }
    else
    { //Hide the DIV.
    OtherEmp.style.display = 'none';
    }
    } //End function ShowHide().
    Here's the call:

    Code:
     
    	 <input type="radio" name="Q14" value="1" onClick="ShowHide(this.form);">
    	 &nbsp; Full-time technical communicator<br>
    	 <input type="radio" name="Q14" value="2" onClick="ShowHide(this.form);">
    	 &nbsp; Part-time technical communicator<br>
    	 <input type="radio" name="Q14" value="3" onClick="ShowHide(this.form);">
    	 &nbsp; Consultant/Independent contractor<br>
    	 <input type="radio" name="Q14" value="4" onClick="ShowHide(this.form);">
    	 &nbsp; Unemployed<br>
    	 <input type="radio" name="Q14" value="5" onClick="ShowHide(this.form);">
    	 &nbsp; Retired<br>
    	 <input type="radio" name="Q14" value="6" onClick="ShowHide(this.form);">
    	 &nbsp; Student<br>
    	 <input type="radio" name="Q14" value="7" onClick="ShowHide(this.form);">
    	 &nbsp; Other
    	 <div id="OtherEmp" style="display: none; margin-left:35px;">
    	 <span class="style3">Please explain below.</span><br />
    	 <input type="text" name="Q14Other" class="q14other" maxlength="90">
    	 </div>
    I'm trying to show/hide the "OtherEmp" <div> depending on which radio button is chosen. I thought this would be a simple task, but it's turning out to be far more of a challenge than I originally thought (my JS is RUSTY!).

    Thanks for any help/advice you might be able to provide.
    Cheers,

    Russ

  2. #2
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The object is document.getElementById('OtherEmp'), not just OtherEmp.

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2001
    Location
    C'Ville, VA
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Ahhh! You're a genius! Thanks a ton.
    Cheers,

    Russ


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •