If I click on radio button, Approver list is not showing up and I can’t find error about that. I will provide both codes and screenshot. Approver should be show as in first picture but it’s not showing anything as can see in second pic.
As in the picture, If I select on Request to Access line, the Approve list should be shown down below.
The Following codes are forom JavaScript.
function ChkArea(){
var area = '';
var a_list = document.getElementsByName('chk_Area[]');
for(z=0;z<a_list.length; z++)
{
if(a_list[z].checked == true)
{
area = area + a_list[z].value + "|";
}
}
document.pac_request.area_listing.value = area;
AsynReqData(reqHttp,'approver_list.php?area=' + area,'RequestForm');
}
function AsynReqData(request,url,fn) { // To send a request to a server
request.open("GET", url + '&sid=' + Math.random(), true);
request.onreadystatechange = eval(fn);
request.send(null);
}
These codes below are for selecting area from 19,23
<?php
include("_dbconn.php");
echo "<script src="ews_pac.js" type="text/javascript"></script>";
$area = isset($_GET["area"])? $_GET["area"] : "";
$list_area = "";
$ary_area = array();
$ary_areano = array();
$sql = "Select distinct(area),area_no from access_request.tbl_access_area order by area_no";
$result = mysqli_query($conn,$sql);
$count = mysqli_num_rows($result);
while($row = mysqli_fetch_array($result)){
$ary_area[] = $row["area"];
$ary_areano[] = $row["area_no"];
}
if($count > 0){
for($i=19;$i<23;$i++){
$list_area .= " <input type="radio" name="chk_Area[]" id="chk_Area".$ary_areano[$i]."" value="".$ary_areano[$i]."" onclick="ChkArea()"><font face="arial" size="2" color="#3C5F84">".$ary_area[$i]."</font>       n";
}
}
echo "<table align="center" border="0" width="95%" bordercolor="#DADADA" cellpadding="3" cellspacing="1">n";
echo "<tr bgcolor="#F5F5F5"><td align="left" colspan="5">n";
echo "<font face="arial" size="2" color="#3C5F84">  Request to Access  </font>";
echo "    ".$list_area;
echo "</td></tr>n";
echo "<tr bgcolor="#F5F5F5"></tr>n";
echo "</table>n";
?>
This part is for approver_list.php
<?php
include("_dbconn.php");
$area = isset($_GET["area"])? $_GET["area"] : "";
if(substr($area,-1) == "|"){
$area = substr($area,0,-1);
}
$area_list = explode("|",$area);
// print_r($area_list);
$area_clause = " area_no in ('" . implode("','", $area_list) . "')";
$ary_approver = array(
"Lay Tian TAN" => "[email protected]",
"Ee-Liang LIM" => "[email protected]",
"Vikas JAIN" => "[email protected]",
"Joseph TEO" => "[email protected]",
"Soon Ik HONG" => "[email protected]",
"Cheng-Lay ANG" => "[email protected]",
"Tun TIN" => "[email protected]",
"Siong Loong WONG" => "[email protected]",
"TW TOH" => "[email protected]",
"David CHOI" => "[email protected]",
"Edwin FONG" => "[email protected]",
"Ken CHEW" => "[email protected]",
"Vincent TAN" => "[email protected]"
);
$sql = "Select distinct(approver_name) from access_request.tbl_access_area where ".$area_clause."";
$result = mysqli_query($conn,$sql);
$cnt = 0;
echo "<table align="center" border="0" width="95%" bordercolor="#DADADA" cellpadding="3" cellspacing="1">n";
echo "<tr bgcolor="#F5F5F5"><td align="left" colspan="5">n";
echo "<font face="arial" size="2" color="#3C5F84">  Approver  </font>";
echo "      ";
while($row = mysqli_fetch_array($result)){
foreach($ary_approver as $k => $v){
if($k == $row["approver_name"]){
echo "<input type="checkbox" id="chkApprover" . $cnt . "" name="chkApprover[]" value="$v" checked disabled><font face="arial" size="2" color="#3C5F84">". $k . "</font>";
echo "<br>          ";
}
}
$cnt++;
}
echo "</td></tr>n";
echo "<tr bgcolor="#F5F5F5"></tr>n";
echo "</table>n";
?>