What im trying to do is changing
dropdown menu values
the Ajax.php files will print
this:
<option value=“…”>…</option>
the problem is i am wrapping other content with the
<div id=“result2”>CONTENT</div>
and for some reason it doesnt work when I wrap content
only when I dont wrap anything it works
like that:
<div id=“result2”></div>
but I want the JQuery to delete the content inside the div and write what he gets from the Ajax.php.
So how can I do that if it won’t work when Im wrapping the content with the div?
<select>
<div id="result2">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</div>
</select>
<script>
function displayVals() {
var singleValues = $("#form1").val();
$.get("ajax.php", { id: singleValues },
function(data){
$( "#result2" ).html(data);
});
}
$("select").change(displayVals);
displayVals();
</script>