Hi all, I'm a beginner in js
I need to create a tree. What do I mean under "a tree"? There have to be some <select>s next to each other. For example, if I have [Electronics->PCs->AMD] here have to be 3 <select>s (first select is general category list, second select is sub-categories of first select and ect. I hope you understand).
And I have a code
var cntOfLevels = 0;
function addCat(id)
if(id == -1) $("#category").html("");
		$.get( "/getCategory.php?id="+id, function(html)
				if(html!="0") $("#catList").html(html);
					document.getElementById("category").value = id;
$res = mysql_query("SELECT id,name FROM categories WHERE parent IS NULL");
echo "<select onchange=\"addCat(this.value);\">";
echo "<option value=\"-1\">Choose item</option>";
while($i = mysql_fetch_assoc($res)) echo "<option value=\"$i[id]\">$i[name]</option>";
echo "</select>";
<span id="catList"></span>
<input type="hidden" name="category" id="category">
But this code works only with two categories, but I may have 3-4. Have you an idea to do it?