Forum Moderators: open
name of second select box is "<select name=Level_1",
third select box is children of second, so the name is: "<select name=Level_2"
forth select box is children of third, so the name is: "<select name=Level_3"
...
I am not sure how I can achieve that, can anyone give me a hint? thanks in advance
function getSub(SelectId) {
var childSelect = $(SelectId); //child select box obj
var url = 'http://kewei-desktop:3000/admin/subcategories/category/' + childSelect.value;
var divIdName = "category_"+childSelect.value+"_div";
// linkInfo is the fiedset which includes the select boxes
if ( $("linkInfo").lastChild.nodeType == 3 ) {
$("linkInfo").removeChild($("linkInfo").lastChild);
}
var currentDiv = childSelect.parentNode;
while ( currentDiv.nextSibling!= null ) {
$("linkInfo").removeChild($("linkInfo").lastChild);
}
new Ajax.Request(url, {
method: 'post',
onSuccess: function(transport) {
var response = transport.responseText;
if ( response.length > 4 ) {
while ( currentDiv.nextSibling!= null ) {
$("linkInfo").removeChild($("linkInfo").lastChild);
}
var tmp = document.createElement("div");
tmp.setAttribute("class", "SubCategory");
tmp.setAttribute("id", divIdName);
tmp.innerHTML = response;
$("linkInfo").appendChild(tmp);
}
}
}
)
}