JQuery issue

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>

Solved
just wrapped the “<select>” too
and its working now.

Your solution is wrong. DIV should never be inside SELECT, remove it. SELECT can include only OPTGROUP and OPTION tags.

Thats what I did… I warpped the whole SELECT
and deleted the div inside…
Thanks anyway :slight_smile:

I am still having problem in running 2 functions in JQuery
help me here if you can