Put this after or below input element. The input element wasn't loaded yet and the javascript is executed so you get null.
Solution 1:
<html>
<head></head>
<body>
<input id="supporter" value="yes" />
<script type="text/javascript">
function show()
{
var supporter = document.getElementById('supporter');
if (supporter.value == "yes")
{
alert("it works")
}
}
show();
</script>
</body>
</html>
Solution 2:
Or if you preffer putting scripts in the head of html, run the function only when the page is loaded.
<html>
<head>
<script type="text/javascript" src="yourcodes.js">
</script>
</head>
<body>
<input id="supporter" value="yes" />
</body>
</html>
On your separate javascript page:
function show()
{
var supporter = document.getElementById('supporter');
if (supporter.value == "yes")
{
alert("it works");
}
}
//When page loaded
document.onload = function(){
show();
};
Note: you don't have to put <script></script>
in your JavaScript file.