Forum Moderators: open

Message Too Old, No Replies

select box name question

         

jj0914

1:22 pm on Aug 23, 2007 (gmt 0)

10+ Year Member



I have a dynamic select box, the way it works is that the appearance of next select box will depend on the selection of previous select box. It is working perfectly for me.
My problem is I want to make the name of each select box like this:

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

Fotiman

4:07 pm on Aug 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You'll need to post the code that you're using to create these select boxes. Can't help you without knowing what you're doing.

jj0914

11:58 am on Aug 24, 2007 (gmt 0)

10+ Year Member



here is my code,

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);
}
}
}
)
}