Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
My project code is this
?>
<html>
<head>
<title>Chat Box</title>
<script>
function submitChat(){
if (form1.uname.value= = ' '|| form1.msg.value = = ' '){
alert('ALL FIELDS ARE MANDATORY'!!!');
return:
}
}
var uname = form1.uname.value;
var msg = form1.msg.value;
var xmlhttp = new XMLHttpRequest();

xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState= =4&&xmlhttp.status= =200){
document.getElementById ('chatlogs').innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open('GET','insert.php?uname='+uname+'&msg='+msg,true);
xmlhttp.send();


}
</script>


</head>
<body>
<form name="form1">
Enter Your Chatname: <input type ="text" name="uname"/>

Your Message:

<textarea name="msg"></textarea>

Send




LOADING CHATLOGS PLEASE WAIT....

</body>
Posted

1 solution

One apparent bug is this: your <script> element is put in the <head> element. This is perfectly fine, but it means it is never executed by itself. Something will be executed only if you call some function from outside. It can be done from some event handler in HTML, or it can be done from the script which is a child of the <body> element.

Also, when asking questions, you need to post comprehensive and correctly formatted code samples. You sample is not like that. It starts with "?>", tags are unbalanced, and so on.

—SA
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900