Hi,
In order to choose categories, I want to use dropdown lists. Each list contains one level of categories. So it's: top level, sub, subsub, subsubsub etc. Every level is dynamically retrieved thru a script 'getcat.php'. It shows a object.
The retrieval so far works with the code underneath. However, Since it's form, i want to get the last selected value so i can have the category id. This however, is not working for me. I tried $("select:last option:selected") but that's not working with the newly inserted elements.
Second part: After selecting the category, an input field must show up where the user can make its own subcategory (inside the category selected). This too, is not working with the new elements.
Now i tried to play something with .live but that doesn't support 'change' events. So, do you guys have any tips on how to improve it? thx a bunch!
Currently I've got the following code:
$("select").bind("change", function(){
$(this).nextAll().remove();
var value = $(this).val();
$("#currentcat").val(value);
if($("select:last option:selected").hasClass('makenew')) {
$("#newcat").show();
}
else if($("select:last option:selected").hasClass('disabled')) { }
else {
$.get("getcat.php", { c: value },
function(data){
$("#getcats").append(data);
});
$("#newcat").hide();
}
});
However, as you can read, it's not a beauty. Tips? thx..