Location: PHPKode > projects > Decider > decider/Initial_Quiz/initialquiztab.php
<?php

	require('../Login/authen.php');

?>
<html>
<head>
<title>Decider - Information Gathering Assistant</title>
<link rel="stylesheet" type="text/css" href="../ajaxtabs/ajaxtabs.css" />
<link rel="stylesheet" type="text/css" href="../common/styles.css" />
<script type="text/javascript" src="../ajaxtabs/ajaxtabs.js">

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

//add Edit quiz page java script code
var edit_selectquiz_req = getXmlHttpRequestObject();
function edit_question(txt){
	//alert(txt);
	chvalue=document.getElementById(txt).value;
	//alert(chvalue);
	if (edit_selectquiz_req.readyState == 4 ||edit_selectquiz_req.readyState == 0) {
		var str = escape(txt);
						
		edit_selectquiz_req.open("GET",'editquiz.php?q_id='+ str+'&quiz='+ chvalue, true);
		edit_selectquiz_req.onreadystatechange = editselect_question; 
		edit_selectquiz_req.send(null);
		
	}		
}

function editselect_question(){
	if (edit_selectquiz_req.readyState == 4) {
	
		
		str=edit_domainkp_req.responseText;
		//alert(str);
		
	}
str=edit_selectquiz_req.responseText();
}


//Ajax object method
function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert("Your Browser Sucks!\nIt's about time to upgrade don't you think?");
	}
}
function textboxes_load(obj){
//alert(obj);
var code="";
	j=0
	for(i=0;i<obj;i++){
		txtid="initial_quiz"+i;
		j++;
		code=code+"<tr ><td valign='top' class='label'>"+j+". Question </td><td><textarea class='textboxarea' cols='40' id='"+txtid+"' name='"+txtid+"' ></textarea></td></tr><br />";
	}
	code=code+'<tr><td></td><td><input type="submit" value="Add" class="button" name="add"><input type="button" value=" cancel " class="button"></td></tr>';	
	//alert(code);
		document.getElementById("ini_quiz").innerHTML=code;
		document.getElementById("number_of_question").value=obj
		//alert(document.getElementById("number_of_question").value);
}

//end of addEditquiz page java script code

//deleteinitialquiz page java script code
var delete_selectquiz_req = getXmlHttpRequestObject();
function delete_question(txt){
	//alert(txt);
	//chvalue=document.getElementById(txt).value;
	//alert(chvalue);
	row="trvalue"+txt;
	document.getElementById(row).innerHTML='';
	if (delete_selectquiz_req.readyState == 4 ||delete_selectquiz_req.readyState == 0) {
		var str = escape(txt);
						
		delete_selectquiz_req.open("GET",'deletequiz.php?q_id='+ str, true);
		delete_selectquiz_req.onreadystatechange = deleteselected_question; 
		delete_selectquiz_req.send(null);
		
	}		
}

function deleteselected_question(){
//this function only for  testing purposes
	if (delete_selectquiz_req.readyState == 4) {
	
		str=delete_selectquiz_req.responseText;
		
	}
//str=delete_selectquiz_req.responseText();
}


//Ajax object method
function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert("Your Browser Sucks!\nIt's about time to upgrade don't you think?");
	}
}

//end of deleteinitial quiz page jav script code


function test(){

	alert("caught");

}


</script> 
<!-- help code-->
<script language="javascript">
var id;
var txtname;
function handleSearchSuggest(txt) {
var str;

			id=txt;
			txtname=txt;		
			var ss = document.getElementById("help");
			ss.innerHTML = '';
			if(id=="addinitialquizhelp"){
		    str = "This form is used to add and edit initial questions";
			}
			if(id=="deleteinitialquizhelp"){
		    str = "This form is used to delete initial questions";
			}
			var suggest = '<div onmouseover="javascript:helpOver(this);" ';
			suggest += 'onmouseout="javascript:helpOut(this);" ';
			suggest += 'onclick="javascript:closeBox(this.innerHTML);" ';
			suggest += 'class="suggest_link">'+ str + '</div>';
			ss.innerHTML += suggest;
			}

//Mouse over function
function helpOver(div_value) {
	div_value.className = 'help_over';
}
//Mouse out function
function helpOut(div_value) {
	div_value.className = 'help_out';
}
//Click function
function closeBox(value) {
	document.getElementById("help").innerHTML = '';
}

</script>
</head>

<body>
<div id='maindiv' align="center" >
<table width="800px"><tr><td align="left" valign="top"><?php require('../common/top.html'); ?></td>
	</tr></table>

<table background="../common/tableback.png" width="800px" height="800px">
<tr align="right"><td></td><td class="label" align="right">
	<?php 
	
echo $_SESSION['username'];
?></td></tr>
	<tr>
	
		<td align="left" valign="top"><?php require('../common/menu.html'); ?></td>
		<td width="600px" align="left" valign="top"><?php require('initialquiztab.html'); ?></td>
	</tr>
</table>
<?php
if(isset($_POST['add'])){

	require("../common/database.php");
	if (!$link)
  	{
  		die('Could not connect: ' . mysql_error());
  	}
	for($i=0;$i<$_POST['number_of_question'];$i++){
	$initial_quiz=initial_quiz.$i;
	
 	$q_string="INSERT INTO initial_quiz VALUES('','$_POST[$initial_quiz]')";
	if (!mysql_query($q_string,$link))
	  {
	  die('Error: ' . mysql_error());
	  }
	 }
	echo "Done..";
	
	mysql_close($link);
	
}
?>
</div>
</body>
</html>
Return current item: Decider