Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
need t know about check box list in javascript ?
how to add check box list item using javascript at runtime?
3 Answers
- ?Lv 41 decade agoFavorite Answer
//pk
<html>
<head>
<title>Test</title>
<script type="text/javascript">
function addItem() {
var currentElement = document.createElement ("input");
currentElement.setAttribute ("type","checkbox");
currentElement.setAttribute ("text","checkbox");
oData.appendChild (currentElement);
}
</script>
</head>
<body>
<SPAN ID="oData" ></SPAN>
<input type="button" value="Create" onclick="addItem()">
</body>
</html>
- 1 decade ago
<head>
<script type="text/javascript">
function addItem() {
var checkbox = document.createElement ("input");
checkbox.type = "checkbox";
checkbox.name = "myCheckbox";
// to check it by default
// checkbox.checked = true;
var insertInto = document.getElementById ("insertInto");
insertInto.appendChild (checkbox);
}
</script>
</head>
<body>
<input type="button" value="Create" onclick="addItem()">
<div id="insertInto"></div>
</body>
Source(s): createElement: http://help.dottoro.com/ljgtgjrs.php appendChild: http://help.dottoro.com/ljvnuman.php