Location: PHPKode > projects > HypatiaDB > hypatiadb/js/rep3.php
<?php header("Content-Type: text/javascript");
include('../common_db.php');
include('../functions.php');
dbconnect($host, $username, $password);
$strings = loadStrings($lang, 'REP3JS');

//This function is responsible for adding the condition to the database
//via a XmlHttpRequest, and adding it visually so that the user can see
//it. Assuming success, it also clears the form elements for the next
//condition to be added.

//TODO: Internet explorer support

$report_id = intval($_REQUEST['rid']);
?>
var r3condReq;
function addCondition() {
	r3condReq = new XMLHttpRequest();
	r3condReq.onreadystatechange = callback;
	r3condReq.open("POST", "xhr/addReportCondition.php");
	r3condReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	r3condReq.send('rid=<?php echo($report_id)?>&lvalue=' + document.getElementById('lvalue').value + '&operator=' + document.getElementById('operator').value + '&rvalue=' + document.getElementById('rvalue').value);
}

function callback() {
	if(r3condReq.readyState == 4) {
		if(r3condReq.status != 200) {
			alert('Server returned a ' + r3condReq.status);
		} else {
			//that worked -- add to the list
			var e = document.getElementById('condlist');
			var src = r3condReq.responseXML.firstChild;
			var nn = document.importNode(src, true);
			e.appendChild(nn);
			document.getElementById('rvalue').value="";
		}
	}
}

var r3killReq;

function removeCondition(id) {
	r3killReq = new XMLHttpRequest();
	r3killReq.open("GET", "xhr/killReportCondition.php?id=" + id);
	r3killReq.send("");
	document.getElementById('condition' + id).parentNode.removeChild(document.getElementById('condition' + id));
}
Return current item: HypatiaDB