Can anyone check out this script? My ajax code doesn't run and the xmlhttp.status is always 0 though it is always 200 in my other scripts. I am sure there is something wrong with my script. Can anyone help me fix it? I tried to debug it for hours but couldn't fix it :(

	require '../includes/connect.inc.php';
<style type='text/css'>
	@import url('../styles/pagestyle.css');
<div id='result'><p class='basicbox'>You can add a maximum of 10 menus. Keep a menu blank if you don't need it.</p></div>
	$query = "SELECT `link_name`,`page_id` FROM `onwebed_menu` WHERE 1";
	if ($mysql_query = mysql_query($query)){
		if (mysql_num_rows($mysql_query)>=1){
			$i = 1;
			while($mysql_row = mysql_fetch_assoc($mysql_query)){
				<div id='basicdiv'>
				<span><?php echo $i." "; ?><input type='text' id='linkname<?php echo $i; ?>' value="<?php echo $mysql_row['link_name']; ?>" class='textboxbasic'>
				<input type='text' id='pageid<?php echo $i; ?>' value="<?php echo $mysql_row['page_id']; ?>" class='textboxbasic'></span><br>
			die('No results found');
		die("There was an error");
<p></p><input type='button' value='Save Changes' class='submitbutton' onclick="editmenu('result','editmenu.inc.php');"/>
<script type='text/javascript'>
	function editmenu(id, file){
		if (window.XMLHttpRequest){
			xmlhttp = new XMLHttpRequest();
			xmlhttp = new ActiveXObject('Microsoft.XMLHttp');
		xmlhttp.onreadystatechange = function(){
			if (xmlhttp.readyState==4 && xmlhttp.status==200){
				document.getElementById(id).innerHTML = xmlhttp.responseText;
		var linkname1 = document.getElementById('linkname1').value;
		var linkname2 = document.getElementById('linkname2').value;
		var linkname3 = document.getElementById('linkname3').value;
		var linkname4 = document.getElementById('linkname4').value;
		var linkname5 = document.getElementById('linkname5').value;
		var linkname6 = document.getElementById('linkname6').value;
		var linkname7 = document.getElementById('linkname7').value;
		var linkname8 = document.getElementById('linkname8').value;
		var linkname9 = document.getElementById('linkname9').value;
		var linkname10 = document.getElementById('linkname10').value;
		var pageid1 = document.getElementById('pageid1').value;
		var pageid2 = document.getElementById('pageid2').value;
		var pageid3 = document.getElementById('pageid3').value;
		var pageid4 = document.getElementById('pageid4').value;
		var pageid5 = document.getElementById('pageid5').value;
		var pageid6 = document.getElementById('pageid6').value;
		var pageid7 = document.getElementById('pageid7').value;
		var pageid8 = document.getElementById('pageid8').value;
		var pageid9 = document.getElementById('pageid9').value;
		var pageid10 = document.getElementById('pageid10').value;
		var querystring = "linkname1="+linkname1+"&linkname2="+linkname2+"&linkname3="+linkname3+"&linkname4="+linkname4+"&linkname5="+linkname5+"&linkname6="+linkname6+"&linkname7="+linkname7+"&linkname8="+linkname8+"&linkname9="+linkname9+"&linkname10="+linkname10;
		xmlhttp.open('POST', file, true);
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
6 Years
Discussion Span
Last Post by ddymacek

first off, if you don't have 10 menu items set, the script will break. for example I only set 5 elements (faking your query and setting items in a for statement), I tried to save one of the five elements I was toying with and immediately go doecument.getElementById("linkname6") is null. javascript error. your code will not work as written. perhaps the better question is, what are you trying to accomplish. take a look at this thread. it is not 'your' issue, but looking at what you are trying to do it is almost the exact same thing I was looking at yesterday, and this guy deraad has some solid code.
I would go to his site and login as guest, look at the functionality of his lists. view page source and look at code in the question asked above.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.