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.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.