Forum Moderators: open
Here is my code:
<html>
<head>
<script language="JavaScript" type="text/JavaScript">
function buildList() {
var span = document.getElementById("list");
// select
var select = document.createElement("select")
var selectAttribute = document.createAttribute("id");
selectAttribute.value = "list";
select.setAttributeNode(selectAttribute);
var selectAttribute = document.createAttribute("onchange");
selectAttribute.value = "alert('event fired');";
select.setAttributeNode(selectAttribute);
// options
var option = document.createElement("option")
selectAttribute = document.createAttribute("value");
selectAttribute.value = "a";
option.setAttributeNode(selectAttribute);
option.appendChild(document.createTextNode(0))
select.appendChild(option)
option = document.createElement("option")
selectAttribute = document.createAttribute("value");
selectAttribute.value = "b";
option.setAttributeNode(selectAttribute);
option.appendChild(document.createTextNode(1))
select.appendChild(option)
span.appendChild(select)
}
</script>
</head>
<body onload="buildList()">
<form name="myform" action="">
<span id="list"></span>
</form>
</body>
</html>
Thanks,
Cian