I cant get the style.display property to work properly. I have this test html page:
Basically, this has a textbox and a hidden gif, and a button called replace. When I click replace, the javascript doesnt do anything.
Code:
<!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>Test Javascript</title>
<script language="javascript" type="text/javascript">
window.onload = function () {
document.getElementById("button").onclick = function () {
var text = document.getElementByName("username");
var loader = document.getElementById("ajax_laoder");
if (loader.style.display == "none") {
text.style.display = "none";
loader.style.display = "inline";
} else {
text.style.display = "inline";
loader.style.display = "none";
}
}
}
</script>
</head>
<body>
<input type="text" name="username" value="Username" class="loginfield" maxlength="60" /><br />
<img src="images/ajax-loader.gif" alt="AJAX Loading" id="ajax_loader" style="display:none" /><br />
<input type="submit" id="button" value="replace" title="Replace" />
Comment