<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Example: Javascript Code to show a hidden object</title>
</head>
<body>
<script type="text/javascript">
//Make Flags Visible or Hidden
function toggleFlags() {
var whichFlag = document.getElementById('whichFlag').value;
if (document.getElementById('flag' + whichFlag).style.display == '') {
document.getElementById('flag' + whichFlag).style.display = 'none';
} else {
document.getElementById('flag' + whichFlag).style.display = '';
}
}
</script>
<form method="post" action="" onsubmit="toggleFlags();return false;">
Enter a number from 1 - 8. Then click the button:
<input type="text" id="whichFlag" name="whichFlag" />
<br>
<input type="submit" name="flagTotal" value="Toggle Flag"/>
<div id="flag1" style="display:none;"><img src="http://www.50states.com/flag/image/nunst064.gif" alt="Pennsylvania"></div>
<div id="flag2" style="display:none;"><img src="http://www.50states.com/flag/image/nunst010.gif" alt="Delaware"></div>
<div id="flag3" style="display:none;"><img src="http://www.50states.com/flag/image/nunst032.gif" alt="Maryland"></div>
<div id="flag4" style="display:none;"><img src="http://www.50states.com/flag/image/nunst030.gif" alt="Maine"></div>
</form>
</body>
</html>
This post has been edited by Atli: 18 October 2012 - 05:06 PM
Reason for edit:: Please use [code] tags when posting code.

New Topic/Question
Reply



MultiQuote




|