Location: PHPKode > projects > Decider > decider/Key_Person/keypersontab.php
<?php

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

?>
<html>
<head>
<title>Decider - Information Gathering Assistant</title>
<script src="clienthint.js"></script> 
<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 language="javascript">

<!--
//Editing part
//also from edit domain part
var show_domainkp_req = getXmlHttpRequestObject();


function show_domain_kp(txt) {
	//alert(txt);
if (show_domainkp_req.readyState == 4 ||show_domainkp_req.readyState == 0) {
		var str = escape(txt);
						
		show_domainkp_req .open("GET",'selectedit.php?domain=' + str, true);
		show_domainkp_req .onreadystatechange =selecttoedit_domainkp; 
		show_domainkp_req.send(null);
		
	}		
}

function selecttoedit_domainkp() {

	if (show_domainkp_req.readyState == 4) {
		str=show_domainkp_req.responseText;
		//alert(str);
		document.getElementById("available_kp").innerHTML=str;		 
	}
}

//Active when click the edit button on the each key person
var edit_domainkp_req = getXmlHttpRequestObject();
function edit_kp(txt){
	//alert(txt);
	chvalue=document.getElementById(txt).value;
	//alert(chvalue);
	if (edit_domainkp_req.readyState == 4 ||edit_domainkp_req.readyState == 0) {
		var str = escape(txt);
						
		edit_domainkp_req.open("GET",'editkp.php?k_id='+ str+'&newkp='+ chvalue, true);
		edit_domainkp_req.onreadystatechange = editselect_domainkp; 
		edit_domainkp_req.send(null);
		
	}		
}

function editselect_domainkp(){
//this method only for my tesing purpose 
//it needn't to work edit part
	if (edit_domainkp_req.readyState == 4) {
	
		str=edit_domainkp_req.responseText;
		//alert(str);
			 
	}
//str=edit_domainkp_req.responseText();
}

//Ajax object method

//this java script is used by the first tab addkeyperson page
//Ajax stuff here
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?");
	}
}
//this function for add key person page
var select_domainkp_req = getXmlHttpRequestObject();


function select_domain_kp(txt) {
	//alert(txt);
if (select_domainkp_req.readyState == 4 ||select_domainkp_req.readyState == 0) {
		var str = escape(txt);
						
		select_domainkp_req .open("GET",'select.php?domain=' + str, true);
		select_domainkp_req .onreadystatechange = handleselect_domainkp; 
		select_domainkp_req.send(null);
		
	}		
}

function handleselect_domainkp() {
//this function handle selected kp form the domain table 
	if (select_domainkp_req.readyState == 4) {
		
		//alert("no of kp=");
		str=select_domainkp_req.responseText;
		document.getElementById("available_kp").innerHTML=str;		 
	}
}
//end of addkeyperson handle page


//end of Ajax stuff

function kpload(obj){
	//this function generate input text box according to the given numbe
	//alert("hello"+obj.value);
	var code="<br>";
	j=0
	for(i=0;i<obj.value;i++){
		txtid="domainkp"+i;
		j++;
		code=code+"<tr ><td class='label'>"+j+". Name </td><td><input type='text' class='textbox' id='"+txtid+"' name='"+txtid+"' /></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("domainkptable").innerHTML=code;
		document.getElementById("number_of_key_person").value=obj.value
		//alert(document.getElementById("number_of_key_person").value);
}
//-->
</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=="addkeypersonhelp"){
		    str = "This form is used to add new key person details";
			}
			if(id=="editkeypersonhelp"){
			str = "This form is used to edit key person details";
			}
			
			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('keypersontab.html'); ?></td>
	</tr>
</table>


</div >
</body>
</html>
<?php 

if(isset($_POST['add'])){

	require("../common/database.php");
	if (!$link)
  	{
  		die('Could not connect: ' . mysql_error());
  	}
	for($i=0;$i<$_POST['number_of_key_person'];$i++){
	$domainkp=domainkp.$i;
	//$q_string="INSERT INTO key_person VALUES('','$_POST[domain_name]','$_POST[$domainkp]')";
 $q_string="INSERT INTO key_person VALUES('','$_POST[domain_name]','$_POST[$domainkp]')";
	if (!mysql_query($q_string,$link))
	  {
	  die('Error: ' . mysql_error());
	  }
	 }
	echo "1 record added";
	
	mysql_close($link);
	
}

?>
Return current item: Decider