Created
April 26, 2016 08:02
-
-
Save btk/df9e6252d74606ca9ced8cf894c532b7 to your computer and use it in GitHub Desktop.
Javascript Select Changer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" lang="tr-TR"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
<script src="js/main.js"></script> | |
<style> | |
.div {width:200px; height:200px; background: #ccc; display:none; } | |
</style> | |
</head> | |
<body> | |
<div class="carrier"> | |
<select id="selectAcil" onchange="degistir()" name="selectAcilName"> | |
<option value="1">İlk Div</option> | |
<option value="2">İkinci Div</option> | |
</select> | |
<div class="div" id="div1">Div 1 içeriği</div> | |
<div class="div" id="div2">Div 2 içeriği</div> | |
</div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onload = degistir; | |
function degistir(){ | |
var select = document.getElementById("selectAcil").value; | |
if(select == 1){ | |
document.getElementById("div1").style.display = "block"; | |
document.getElementById("div2").style.display = "none"; | |
}else if(select == 2){ | |
document.getElementById("div2").style.display = "block"; | |
document.getElementById("div1").style.display = "none"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment