I am trying to use appendChild() to append another div block to a previous div block. but for some reason I can't append to it.
here is my code:
"response" variable holds result like this:
"Container" is the id of my previous div
"Parent" is the id of my select box id(this select box is inside div)
Can anyone help me on this? Thanks in advance
here is my code:
Code:
<script type="text/javascript">
function getSubCat(Parent, Container) {
var parent = $(Parent);
var url = '[URL unfurl="true"]http://kewei-desktop:3000/admin/subcategories/category/'[/URL] + parent.value;
new Ajax.Request(url, {
method: 'post',
onSuccess: function(transport) {
var response = transport.responseText;
if ( response ) {
$(Container).appendChild(response);
}
else {
$(Container).removeChild(response);
}
}
}
)
}
</script>
"response" variable holds result like this:
"Container" is the id of my previous div
"Parent" is the id of my select box id(this select box is inside div)
Code:
<div class="SubCategory" id="category_2_children">
<label for="SubCategory">
SubCategory :
</label><br>
<select name="children" id="children">
<option value=""></option>
<option value="16">Dictionaries and Reference</option>
<option value="44">Disabilities</option>
<option value="18">Distance Education</option>
<option value="7">Electronic Communication</option>
<option value="13">Employment Readiness</option>
<option value="19">English as a Second Language (ESL)</option>
<option value="12">Family Literacy </option>
<option value="3">General Educational Resources</option>
<option value="195">Health</option>
<option value="77">Justice and Corrections</option>
<option value="27">Libraries </option>
<option value="28">Museums </option>
<option value="37">Plain/Clear Language </option>
<option value="38">Professional Development</option>
<option value="17">Research Tools</option>
<option value="40">Software</option>
<option value="15">Special Education</option>
<option value="6">Subject Areas</option>
<option value="39">Workplace Literacy</option>
</select>
</div>
Can anyone help me on this? Thanks in advance