Skip to content

Instantly share code, notes, and snippets.

@Zillionx
Last active December 2, 2015 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zillionx/1251106324abbc69f189 to your computer and use it in GitHub Desktop.
Save Zillionx/1251106324abbc69f189 to your computer and use it in GitHub Desktop.
Show Div when selectedIndex Property != 0
<!doctype html>
<!-- http://www.w3schools.com/jsref/prop_select_selectedindex.asp -->
<html>
<head>
<meta charset="UTF-8">
<title>tst</title>
<script type="text/javascript">
function ShowDiv() {
if (document.getElementById('Country').selectedIndex != 0 ) {
document.getElementById('Show').style.display = 'block';
}
else document.getElementById('Show').style.display = 'none';
}
</script>
</head>
<body>
<select onchange="javascript:ShowDiv();" name="Country" id="Country">
<option selected="selected">select country</option>
<option>italy</option>
<option>uk</option>
<option>us</option>
</select>
<div id="Show" style="display:none">
<p>Show div</p>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment