Jump to content

how to hide/show label along with drop down menu?


matt121400

Recommended Posts

ok i am able to hide/show the menu based on a radio button but how would i also be able to hide/show the label that corresponds to the menu also?

I have included the code i am currently using

thanks!

 

<input type="radio" input onclick="javascript:document.getElementById('relocate').style.visibility='visible'" name="relocate2" class="fieldradio" onclick="relocate2Change(this);" />
    yes
    <input type="radio" name="relocate2"   class="fieldradio"   onclick="relocate2Change(this);" />
    No    </span>  </p>
    
<LABEL for="relocate">Relocation: </LABEL><select name="relocate" id="relocate" style="visibility:hidden"/>


  <option value="No" checked='checked'>No Relocation</option>
    <option value=N"Alabama">Alabama</option>
  <option value="Alaska">Alaska</option>
  <option value="Arizona">Arizona</option>
  <option value="Arkansas">Arkansas</option>
  <option value="California">California</option>
  <option value="Colorado">Colorado</option>
    </select>

Link to comment
Share on other sites

You can make two calls within an even trigger like so:

onclick="function1();function2()"

 

But you shouldn't do that in this case. It is better to separate the javascript from the presentation. Also, you can make it much easier by just putting a span around the label and the select list and just changing the visibility of the span:

 

<html>
<head>

<script type="text/javascript">
  function showRelo(visiState)
  {
    document.getElementById('reloSpan').style.visibility = visiState;
  }
</script>

</head>
<body>

<input type="radio" name="relocate2" class="fieldradio" onclick="showRelo('visible');" />Yes
<input type="radio" name="relocate2" class="fieldradio" onclick="showRelo('hidden');" checked="checked" />No
<br />
<span id="reloSpan" style="visibility:hidden">    
<label for="relocate">Relocation:</label>
<select name="relocate" id="relocate">
  <option value="No" checked='checked'>No Relocation</option>
  <option value=N"Alabama">Alabama</option>
  <option value="Alaska">Alaska</option>
  <option value="Arizona">Arizona</option>
  <option value="Arkansas">Arkansas</option>
  <option value="California">California</option>
  <option value="Colorado">Colorado</option>
</select>
</span>

</body> 
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.