Jump to content

[SOLVED] IE Problem with Form


dfowler

Recommended Posts

Hey guys, I have some AJAX from a tutorial on this site that works perfectly with Firefox, but doesn't work AT ALL with IE.  I was hoping somebody can take a look and see if I am missing something.

 

AJAX Function - header.php

<script type="text/javascript">
function ajaxFunction(ID, Param) {
var loaderphp = "<?php echo $_SERVER['PHP_SELF'] ?>";

//test browsers
var xmlHttp;
try {
	// Firefox, Opera 8.0+, Safari
	xmlHttp=new XMLHttpRequest();
} catch(e) {
	// Internet Explorer
	try {
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	} catch(e) {
		try {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		} catch(e) {
			alert("Your browser does not support AJAX!");
			return false;
		}
	}
}
xmlHttp.onreadystatechange=function() {
	if(xmlHttp.readyState==4) {
		document.getElementById(ID).innerHTML = xmlHttp.responseText;
	}
}
xmlHttp.open("GET", loaderphp+"?Param="+Param,true);
xmlHttp.send(null);
}
</script>

 

 

Form - 1.php

<?php
include 'header.php';

//FIRST list box
$query = "select * from table_a where active='1'";
$list1 = array();
$result=mysql_query($query);
while (($row = mysql_fetch_assoc($result)) !== false) {
	$list1[] = $row;
}

if(isset($_GET['Param']) )
{
	$NewData = "";
	$P = $_GET['Param'];

	if (!mysql_query("SELECT * FROM table_b WHERE a_id='$P'")) {
		echo "Database is down";
	}
	$query = "select * from table_b where active='1' and a_id='$P'";
	$result = mysql_query($query);
	while (($row = mysql_fetch_assoc($result)) !== false) {
		$NewData .= "<option value='".$row['id']."'>".$row['name']."</option>\n";
	}
	echo $NewData; //Send Data back
	exit;
}
?>
<form method="post" enctype="multipart/form-data" name="myForm" target="_self" action="2.php">
<table border="0">
<tr>
	<td>Option A:<select name="list1" onChange="ajaxFunction('LBox2', this.value);">
			<option value=''></option>
		<?php 
			foreach($list1 as $l)
			{ ?>
			<option value="<?php echo $l['id']; ?>"><?php echo $l['name']; ?></option>
			<?php } ?>
	</select>
	</td>
	<td>Option B:<select name="list2" id="LBox2">
	</select>
	</td>
</tr>
</table>
  <input type="submit" name="Submit" value="Submit" />
</form>
<?php
include 'footer.php';
?>

 

 

Just to clarify, the form loads up on IE, but when you pick an option in the first select box nothing happens to the second select box.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.