Solved

error is:- content is not a function. why the function is not called

Posted on 2009-07-13
6
198 Views
Last Modified: 2012-05-07
error is:- content is not a function. why the function is not called
<?php

	$db_host="localhost";

		$db_name="fck";

		$username="root";

		$password="";

		$db_con=mysql_connect($db_host,$username,$password) or die("connection not build".mysql_error());

		$db=mysql_select_db($db_name) or die("database not build".mysql_error());

?>

<script language="javascript" type="text/javascript">

function createObject() {

	var request_type;

	var browser = navigator.appName;

	if(browser == "Microsoft Internet Explorer"){

		request_type = new ActiveXObject("Microsoft.XMLHTTP");

	} else{

		request_type = new XMLHttpRequest();

	}

	return request_type;

}

var http = createObject();
 

function content(){

	var content = encodeURI(document.getElementById('content').value);

	alert(content)

	http.open('get','content.php?content='+content, true); 

	http.onreadystatechange = function(){

	if(http.readyState == 4){

		var response = http.responseText;

		document.getElementById('test').innerHTML = response;

		document.getElementById('test').style.display = 'block';

		}

	}

	http.send(null);

}
 
 

</script>

<form> 

<table border="1" bgcolor="#CCCCCC" width="10%">

<tr><td colspan="2" align="center"><h2>Add Form</h2></td></tr>

<tr><td colspan="2">

	<?php

		$sql = "select * from `fck`";

		$qid = mysql_query($sql) or die("could not select".mysql_error());

		while($rec=mysql_fetch_array($qid)){

			echo $content_value = $rec['content'];

		}

	?>

	</td></tr>

<tr><td><h4>Content</h4></td><td><input type="text" name="content" id="content" value="<?php echo $content_value; ?>" /></td></tr>

<tr><td colspan="2" align="center"><input type="button" name="button" value="Add" onclick="javascript:content()" /></td></tr>

</table>

</form>

<div id="test"></div>

Open in new window

0
Comment
Question by:designersx
  • 3
  • 2
6 Comments
 
LVL 41

Accepted Solution

by:
HonorGod earned 125 total points
ID: 24839306
Because you reuse the variable name "content" as the name of your function,
then immediately within the function with this statement:


var content = encodeURI(document.getElementById('content').value);

Open in new window

0
 

Author Comment

by:designersx
ID: 24839432
yes sir solved that issue thanks

sir what is the meaning of the below error.

Catchable fatal error: Object of class stdClass could not be converted to string in C:\wamp\www\new\modified_cms\login\dat.php on line 39
0
 
LVL 29

Expert Comment

by:Badotz
ID: 24839474
The function named "content", the variable named "content" within the function and the HTML element with the ID of "content" are separate entities and should *not* be a problem.

It is confusing as all get out, but it remains valid.

This:

onclick="javascript:content()"

should be this:

onclick="content();"
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:designersx
ID: 24839671
>>onclick="javascript:content()"
should be this:
onclick="content();"

with this the problem persists

you must have noticed that above i have input type=button , therefore the problem is coming, when i take input type=submit then problem does not come.

and my above gets solved when i apply ur first idea of changing the function name with the id.

ok no probs , now my problem is being solved thanks for that.
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 24839805
I don't know that a stdClass is.  That is not a standard JavaScript object.
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 24840045
Thank you for the grade & points.

Good luck & have a great day.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Calculate values in an array 18 33
Ajax Panel Not Updating When Triggered By Timer 4 40
get domain with php 7 19
WP_Query multiple custom taxonomies 5 27
jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now