Zvona
07-30-2002, 01:34 PM
Edit : Blue parts are added after jkd's suggestion.
Following code does not work on IE. Moz handles it nicely.
Can anybody say, how to set for IE whether checbox is checked? I've tried also setAttribute() and to set checked property to "checked", but none of these works on IE :(.
<!-- Example Written by Zvona -->
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Creating a checked checkbox</title>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1;" />
<script type="text/javascript">
window.onload = function()
{
var oForm = document.createElement("form");
var oCheckB = document.createElement("input");
var oButton = document.createElement("input");
oCheckB.setAttribute("type","checkbox");
oCheckB.checked = true;
oButton.setAttribute("type","button");
oButton.onclick = function()
{
document.forms[0].elements[0].checked = !oCheckB.checked;
}
oForm.appendChild(oCheckB);
oForm.appendChild(oButton);
document.body.appendChild(oForm);
}
</script>
</head>
<body>
</body>
</html>
Following code does not work on IE. Moz handles it nicely.
Can anybody say, how to set for IE whether checbox is checked? I've tried also setAttribute() and to set checked property to "checked", but none of these works on IE :(.
<!-- Example Written by Zvona -->
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Creating a checked checkbox</title>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1;" />
<script type="text/javascript">
window.onload = function()
{
var oForm = document.createElement("form");
var oCheckB = document.createElement("input");
var oButton = document.createElement("input");
oCheckB.setAttribute("type","checkbox");
oCheckB.checked = true;
oButton.setAttribute("type","button");
oButton.onclick = function()
{
document.forms[0].elements[0].checked = !oCheckB.checked;
}
oForm.appendChild(oCheckB);
oForm.appendChild(oButton);
document.body.appendChild(oForm);
}
</script>
</head>
<body>
</body>
</html>