Jump to content

[SOLVED] Hide and Unhide a div with a selectbox


ramli

Recommended Posts

I want to unhide a div depending on the value of a selectbox option value

 


<script type="text/javascript" language="JavaScript" src="subform.js"></script>

<form name='template'>
<select name='choise' onchange="javascript:ShowContent('value of option')">
<option value="uniquename">uniquename</option>
</select>
</form>

----------- This is the way it does work only this is a link.
<a 
   onmouseover="ShowContent('uniquename'); return true;"
   href="javascript:ShowContent('uniquename')">
[show]
</a>

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

<div 
   id="uniquename" 
   style="display:none; 
      left:200px; 
      top:100px; 
      border-style: solid; 
      background-color: white; 
      padding: 5px;">

Content goes here.

</div>



 

code in subform.js:

 

function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "block";
}
function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }
}

 

as you can see i got some of the work done  ;). However i dont know how to read the value in the onchance handeler. can sombody help me pleace.

 

 

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.