Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 08-08-2007, 09:34 AM   #1 (permalink)
markster
Code Monkey
 
markster's Avatar
 
Join Date: Jun 2006
Posts: 65
markster is on a distinguished road
Question Object Does Not Support This Property or Method

Can anyone see whats the problem with this code?

HTML Code:
<script type="text/javascript">
var xmlHttp;
function stateChanged() { 
	if (xmlHttp.readyState==4) { 
		document.getElementById("mysql_check").innerHTML=xmlHttp.responseText;
	}
}
function getXmlHttpObject() {
	var xmlHttp = null;
	if (window.ActiveXObject) {
  		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
 	} else if (window.XMLHttpRequest) {
  		xmlHttp = new XMLHttpRequest();
 	}
	return xmlHttp;
}
function mysqlReset() {
	document.getElementById("mysql_check").innerHTML = "<input type=\"button\" value=\"Check Connection\" onClick=\"mysqlCheck()\">"
}
function mysqlCheck() {
	document.getElementById("mysql_check").innerHTML = "Checking...";
	var host = document.getElementById("mysql_host").value;
	var user = document.getElementById("mysql_user").value;
	var pass = document.getElementById("mysql_pass").value;
	var db = document.getElementById("mysql_db").value;
	if (host.length==0 || user.length==0 || pass.length==0 || db.length==0) {
		alert("Please fill in all fields");
		mysqlReset();
		return;
	}
	xmlHttp = getXmlHttpObject;
	if (xmlHttp==null) {
		alert("Your browser doesn't suppert AJAX which is needed to check your connection");
		mysqlReset();
		return;
	}
	var url = "http://www.stuff4web.co.uk/SCMS/admin_check_mysql.php?h="+host+"&u="+user+"&p="+pass+"&d="+db+"&s="+Math.random()*10;
	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.open("GET",url,true);          // LINE 74
	xmlHttp.send(null);
}
</script>
I am getting the error "Object doesn't support this property or method" on line 74 (maked above)
__________________
Stuff4Web.co.uk - The ultimate resource for webmasters

50% off all orders £1-£50! Just enter the code AGSIG01 at the checkout! Offer ends: 01/09/2008
markster is offline   Reply With Quote
Old 08-08-2007, 01:57 PM   #2 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 673
DJMaze is on a distinguished road
1. You are using crappy Internet Explorer
2. You don't follow W3C standards/rules

Result: Not line 74 but line 5: .innerHTML is not allowed.
__________________

UT: Ultra-kill... God like!
DJMaze is offline   Reply With Quote
Old 08-08-2007, 04:00 PM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,487
sde is on a distinguished road
Definitely use Firefox with the 'firebug' plugin for debugging stuff like this.

DJM, how did you come to that conclusion without seeing if his HTML included an element for mysql_check which supported innerHTML?
__________________
Mike
sde is offline   Reply With Quote
Old 08-09-2007, 12:07 AM   #4 (permalink)
markster
Code Monkey
 
markster's Avatar
 
Join Date: Jun 2006
Posts: 65
markster is on a distinguished road
Just a quick note, all reply messages are being printed into <span id="mysql_check"></span>. I thought innerHTML was allowed for them?
__________________
Stuff4Web.co.uk - The ultimate resource for webmasters

50% off all orders £1-£50! Just enter the code AGSIG01 at the checkout! Offer ends: 01/09/2008
markster is offline   Reply With Quote
Old 08-09-2007, 12:22 AM   #5 (permalink)
markster
Code Monkey
 
markster's Avatar
 
Join Date: Jun 2006
Posts: 65
markster is on a distinguished road
In IE I get the error message I told you about earlier, in FF nothing happens, the script just stops. It's completely got me and I can't see a problem anywhere. Here is the whole HTML for the page:

HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Admin Control Panel - Settings</title>
<link rel="stylesheet" href="http://www.stuff4web.co.uk/SCMS/skins/basic_skin/style.css" media="screen" type="text/css" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body>
<div id="container">

<div id="header">
<img src="http://www.stuff4web.co.uk/SCMS/skins/basic_skin/images/logo.png" alt="Name of your site" />
</div>

<table width="100%">
<tr valign="top"><td width="175px">

<div id="navigation">
<h3>Main Menu
</h3>&nbsp;&nbsp;&bull;&nbsp;<a href="index.php?p=home">Home</a><br />
&nbsp;&nbsp;&bull;&nbsp;<a href="index.php?p=bbcode">BB Code</a><br />


</div>

</td><td>

<div id="content">
<h1>Admin Control Panel - Settings</h1>
<script type="text/javascript">
var xmlHttp;
function stateChanged() { 
	if (xmlHttp.readyState==4) { 
		document.getElementById("mysql_check").innerHTML = xmlHttp.responseText;
	}
}
function getXmlHttpObject() {
	var xmlHttp = null;
	if (window.ActiveXObject) {
  		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
 	} else if (window.XMLHttpRequest) {
  		xmlHttp = new XMLHttpRequest();
 	}
	return xmlHttp;
}
function mysqlReset() {
	document.getElementById("mysql_check").innerHTML = "<input type=\"button\" value=\"Check Connection\" onClick=\"mysqlCheck()\">"
}
function mysqlCheck() {
	document.getElementById("mysql_check").innerHTML = "Checking...";
	var host = document.getElementById("mysql_host").value;
	var user = document.getElementById("mysql_user").value;
	var pass = document.getElementById("mysql_pass").value;
	var db = document.getElementById("mysql_db").value;
	if (host.length==0 || user.length==0 || pass.length==0 || db.length==0) {
		alert("Please fill in all fields");
		mysqlReset();
		return;
	}
	xmlHttp = getXmlHttpObject;
	if (xmlHttp==null) {
		alert("Your browser doesn't suppert AJAX which is needed to check your connection");
		mysqlReset();
		return;
	}
	var url = "http://www.stuff4web.co.uk/SCMS/admin_check_mysql.php?h="+host+"&u="+user+"&p="+pass+"&d="+db+"&s="+Math.random()*10;
	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
</script>
<p>Below are all the settings for your site. From here you can review them or make edits to them.</p>
<form action="admin_settings.php" method="post">
MySQL Host:<br>
<input type="text" name="mysql_host" value="[REMOVED BY ME]" id="mysql_host" onKeyDown="mysqlReset()"><br><br>
MySQL Username:<br>
<input type="text" name="mysql_user" value="stuff4web" id="mysql_user" onKeyDown="mysqlReset()"><br><br>
MySQL Password:<br>
<input type="password" name="mysql_pass" id="mysql_pass" onKeyDown="mysqlReset()"><br><br>
MySQL Database:<br>
<input type="text" name="mysql_database" value="stuff4web" id="mysql_db" onKeyDown="mysqlReset()">
<span id="mysql_check"></span><br><br>
Base URL of SimpleCMS Folder:<br>
<input type="text" name="baseUrl" value="http://www.stuff4web.co.uk/SCMS/">

</div>

</td></tr>
</table>

</div>
</body>
</html>
__________________
Stuff4Web.co.uk - The ultimate resource for webmasters

50% off all orders £1-£50! Just enter the code AGSIG01 at the checkout! Offer ends: 01/09/2008

Last edited by markster; 08-09-2007 at 12:23 AM. Reason: Spelling error
markster is offline   Reply With Quote
Old 08-09-2007, 12:40 AM   #6 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 673
DJMaze is on a distinguished road
Quote:
Originally Posted by sde View Post
DJM, how did you come to that conclusion without seeing if his HTML included an element for mysql_check which supported innerHTML?
Most people don't use block elements (like div and fieldset) to place data.
This due to the problem with block elements being on their own row instead of inline with elements (like input tags).
Since only block elements are allowed to use innerHTML the issue is easy.

a. FireFox does allow innerHTML on all elements
b. IE only on block elements

As for superior debugging in Firefox: Firebug - Web Development Evolved
__________________

UT: Ultra-kill... God like!
DJMaze is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
help me.. how to apply inheritance&polymorphsm in GUI ice Java 7 03-27-2006 12:27 PM


All times are GMT -8. The time now is 02:15 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting