Infolinks In Text Ads

Jul 24, 2010

make drop down list in javascript example

Make dynamic drop down list in java script.


<html>
<head>
<script>
function makeDropDown(){
    var formDiv = document.getElementById("div");
    var selectTag=document.createElement("select");
    selectTag.appendChild(getOption("First Value", "First Text"));
    selectTag.appendChild(getOption("Second Value", "Second Text"));
    formDiv.appendChild(selectTag);
}

function getOption(value, text){
    var optionTag = document.createElement("option");
    var text = document.createTextNode(text);
    optionTag.setAttribute("value", value);
    optionTag.appendChild(text);
    return optionTag;
}
</script>
</head>
<body onload="makeDropDown()">
<div id="div"></div>
</body>
</html>

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...