Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 531
0 Users 3 Guests Online
Forum Index » PHP + MySQL » Javascript on POST refresh tex
Posted on Tuesday 7th August 2007 at 01:53 AM
Diablosblizz
templates/default/images/noavatar.png's Avatar
Senior Member
I am not sure if this is Javascript, but I was able to find this in RMB's source:

Code
<script type="text/javascript">
var xmlHttp
function GetXmlHttpObject(){
var objXMLHttp=null
if (window.XMLHttpRequest){
objXMLHttp=new XMLHttpRequest()
}else if (window.ActiveXObject){
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}
function GetShouts(){
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null){
alert ("Browser does not support HTTP Request")
return
}
var url="http://rmb-scripting.com/showshouts.php"
xmlHttp.open("GET",url,true)
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200 || xmlHttp.status == 0) {
document.getElementById('shouts').innerHTML = xmlHttp.responseText;
}
}
};
xmlHttp.send(null);
}

GetShouts();
setInterval("GetShouts()",30000);

function ShoutIt(){
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null){
alert ("Browser does not support HTTP Request")
return
}
if(document.shout.message.value == "" || document.shout.message.value == "NULL"){
alert('Please enter your message.');
return;
}
xmlHttp.open('POST', 'http://rmb-scripting.com/addshout.php');
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttp.send('message='+document.shout.message.value);
document.shout.message.value = '';
document.shout.message.focus();
GetShouts();
}
</script>


It's the Shoutit() javascript used in:

Code
<form method='post' onsubmit='ShoutIt();return false;' name='shout'>



Okay, what I want:

If you post in RMB's shoutbox when you press enter or press "shout" the message in the textarea goes away, how am I able to do that with my site?

Thanks!