...

View Full Version : displaying checkbox on the screen



madhu9124
12-31-2011, 12:56 PM
Hi friends,
I have a dropdown menu,when i select one item from the dropdown menu,i want a checkbox to be created on the screen.How do i achieve this?

Thank You
Madhusudan

kloMan
12-31-2011, 02:21 PM
Use document.createElement() and element.appendChild() to manipulate the DOM tree...

Philip M
12-31-2011, 03:43 PM
No need to "manipulate the DOM tree". Use this:-



<select id = "mysel" onchange = "showbox()">
<option value = 0>Select an option....</option>
<option value = 1>Option One</option>
<option value = 2>Option Two</option>
<option value = 3>Option Three</option>
</select>

<div id = "boxcontainer" style="display:none">
Check this box <input type = "checkbox" id = "chk1">
</div>

<script type = "text/javascript">

function showbox() {
document.getElementById("boxcontainer").style.display="none"; // hide the checkbox
document.getElementById("chk1").checked = false; // uncheck if a different option is chosen
var val = document.getElementById("mysel").selectedIndex;
if (val == 3) { // or whatever option applies
document.getElementById("boxcontainer").style.display="inline"; // show the checkbox
}

}
</script>

Quizmaster: What is a chaffinch?
Contestant: It is a measurement



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum