-
help with list checkboxes
Hello everybody, i'm starting with javascript and i have this problem: if you select an item in a dropdownlist then you should get a list of checkboxes acording to the item selected. The problem is that i need the checkboxlist inside a particular div (div id='products'). How can i do it? This is the code i have:
<script>
function favBrowser(){
var listCheckboxes ="";
var mylist=document.getElementById("myList");
valueSelected = mylist.options[mylist.selectedIndex].value;
switch (valueSelected)
{case "Fruits":
var product = new Array();
product[0] = "apple";
product[1] = "banana";
product[2] = "ananas";
break;
case "Vegetables":
var product = new Array();
product[0] = "carrot";
product[1] = "peper";
product[2] = "tomate";
break;
case "Fish":
var product = new Array();
product[0] = "Salmon";
product[1] = "tuna";
product[2] = "octopus";
break;
}
for (x in product)
{
listCheckboxes += "<input type='checkbox' value='"+ mycars[x] +"'>" + mycars[x] + "<br />";}
document.getElementById('products').innerHTML = listCheckboxes;
}
}
</script>
<body>
<div id="content">
<form><select id="myList" onChange="favBrowser()">
<option selected>
<option value="Fruits">Fruits</option>
<option value="Groenten">Groenten</option>
<option value="Conservas">Conservas</option>
</select></form>
</div>
<div id="products"></div>
</body>
Last edited by lalein; 05-12-2008 at 11:15 AM.
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks