I've literally copy and pasted a basic AJAX function from W3 Schools, and for some odd reason it refuses to work on my site...please help.

Here is my HTML:

<select name="address" onChange="sortAddress(this.value)">
	<option value="" selected="selected">Building Address</option>
	$sql = "SELECT DISTINCT name FROM buildings ORDER BY location";
	 $result = mysql_query($sql);
	  while($r=mysql_fetch_array($result)) {
	 <option value="<?=$r['name']; ?>"><?=$r['name']; ?></option>
	 <?php } ?>

Below is the AJAX I am using.

The bold line errors "Object doesn't support this property or method"

function sortAddress(str)
if (str=="")
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
 [B] xmlhttp=new XMLHttpRequest();[/B]
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  if (xmlhttp.readyState==4 && xmlhttp.status==200)

I am running this function on:

The page works through a combo box form element. When the user selects the "building", the building information is supposed to display directly below it. Any help is greatly appreciated.

Sorry everyone, I actually solved this in just a few minutes.

The problem was my original select item had a blank value:

<option value="" selected="selected">Building Address</option>

When I assigned a value it worked just fine:

<option value="Building Address" selected="selected">Building Address</option>

This leads me to believe that IE will not accept a "blank" value, which makes me curse Microsoft even more.