View Single Post
Old 04-03-2009, 11:49 AM   PM User | #3
pigro
New Coder

 
Join Date: Mar 2009
Location: Milan
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
pigro is an unknown quantity at this point
I've resolved something )

The timed script and insert query is working now!
The query is creating rows but i can't see $_POST[girl] and $_POST[prive] values into DB

Code:
 div style="position:relative; width:400px; display:block; ">
<form name="form1" method="post" action="javascript:insert();">
<div class="form">ragazza: 
	<? catch_girl($query,$girl); ?>
</div>
<div class="form">priv&eacute;: 
	<select class="box" name="prive" id="prive" onFocus="className='focused';" onBlur="className='box';">
    	<option value="0" selected="selected">0</option>
		<option value="1">1</option>
		<option value="2">2</option>
		<option value="3">3</option>
    </select>
</div>  
<div class="form" style="padding-top:10px;"><span class="button"> <input type="submit" name="activity" value="inserisci" /></span></div>
<div style="position:absolute; margin-left:2px; top:1px; right:1px;">
 <textarea style="background-color:#CCCCCC;" name="girlvalue" readonly="readonly" cols="20" rows="15" id="girlvalue">
  </textarea>
</div>
</form>
</div>
<script 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();

var nocache = 0;
function insert() {
// Optional: Show a waiting message in the layer with ID login_response
document.getElementById('insert_response').innerHTML = "Just a second..."
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
var girl= encodeURI(document.getElementById('girl').value);
var prive = encodeURI(document.getElementById('prive').value);
// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
http.open('post', 'query_activity.php?girl='+girl+'&prive=' +prive+'&nocache = '+nocache);
http.onreadystatechange = insertReply;
http.send(null);
addItem();
}

function insertReply() {
if(http.readyState == 4){
var response = http.responseText;

document.getElementById('insert_response').innerHTML = 'Activity inserted:'+response;
}
}




var atext = new Array();
var atim = new Array()
var otext = "Ragazze Impegnate: \n";
document.getElementById("girlvalue").value = otext;


//var showtime = 300000;  // milliseconds = 5 minutes
var showtime = 600000 // 10 seconds for test purposes

window.setInterval("showtext()",1000);  // refresh every 1 second

function showtext() {
var now = new Date().getTime();
var string = otext;
for (var i =0; i <= atext.length; i++) {
if ((atim[i] + showtime) > now) {
string = string + "\n" + atext[i];
string = string.replace(/\s+/g," ");
}
document.getElementById("girlvalue").value = string;
}
}

function addItem() {
var b = document.getElementById("girl").value;
atext.push(b);
var now = new Date().getTime();
atim.push(now);
document.getElementById("girl").value = document.getElementById("girl").value;

}

</script>
pigro is offline   Reply With Quote