Skip to content
Advertisement

If I click on Tab, it doesn’t response. Why?

Problem is I cannot click the Tabs on the website and If i click on Tabs; it show

Uncaught Type Error: Cannot set properties of null (setting ‘value’).

Is there any way to fix this? Also, I am a beginner and I don’t know how to fix this. Codes are written in PHP and Javascript.

    <?php
// session_start();
require("checklogin.php");

$toolsname = "Matrix Setup";
$toolsnamepath = "index.php";
$userlogin = $loginname;
$usrgroup = $_SESSION["usrgrp"];

$str_tab = isset($_POST["str_tab"])? $_POST["str_tab"] : "";
$winwidth = isset($_POST["winwidth"])? $_POST["winwidth"] : "";
$ch = isset($_POST["ch"])? $_POST["ch"] : "";
$badgeno = isset($_SESSION["badgeno"])? $_SESSION["badgeno"] : "";

if($str_tab == ""){
  $str_tab = isset($_GET["str_tab"])? $_GET["str_tab"] : "";
}
if($winwidth == ""){
  $winwidth = isset($_GET["winwidth"])? $_GET["winwidth"] : "";
}
if($ch == ""){
  $ch = isset($_GET["ch"])? $_GET["ch"] : "";
}

echo "<html>";

echo "<head><title>$toolsname</title>";
echo "<meta http-equiv="X-UA-Compatible" content="IE=5">";
echo "<meta name="viewport" content="width=device-width, initial-scale=1">";
echo "<link rel="stylesheet" type="text/css" href="web/css/lotmgt_edge.css"/>";
echo "<script src="lotmgt.js"></script>n";
echo "<script src="setup/setup.js"></script>n";
echo "<script src="productmatrix/productmatrix.js"></script>n";
echo "<script src="simulator/simulator.js"></script>n";
echo "<script src="addmatrix/addmatrix.js"></script>n";
echo "<script src="addAVImatrix/addmatrix.js"></script>n";
echo "<script src="web/js/eregister/pointer.js" type="text/javascript"></script>";

echo "</head>";

  echo "<body onload=OnLoad('" . $ch . "','" . $badgeno . "')>";

  //include($_SERVER['DOCUMENT_ROOT']."librarycommonapewsheader.php");
  //include($_SERVER['DOCUMENT_ROOT']."librarycommondb_config.inc");
  //include($_SERVER['DOCUMENT_ROOT']."librarycommonstandard_defines.inc");
  include("//sgewsnant21.amk.st.com/ewsweb/wwwroot/library/common7/apewsheader.php");
  include("//sgewsnant21.amk.st.com/ewsweb/wwwroot/library/common7/db_config.inc");
  include("//sgewsnant21.amk.st.com/ewsweb/wwwroot/library/common7/standard_defines.inc");
  include("editme.php");

    echo "<form name="lotmgt" method="post" target="_self" onsubmit="return false;">";

      echo "<div style="position:relative; top:20px;">";
        echo "<table cellpadding="3" cellspacing="0" border="0" width="99%">";
            echo "<tr>";
                echo "<td>";

                    for($c=0;$c<count($ary_tab);$c++) {
                        
                    $class_tab = (($ch=="ProductMatrix" && $ary_tab[$c]=="Product Matrix" && (!isset($str_tab) || $tr_tab=="")) || ($ch=="SocketSimulator" && $ary_tab[$c]=="Socket Simulator" && (!isset($str_tab) || $str_tab=="")) || ($ch=="AVIMatrixAdd" && $ary_tab[$c]=="AVI Matrix Add" && (!isset($str_tab) || $str_tab=="")) || ($ch=="SetupPostTest" && $ary_tab[$c]=="Setup PostTest" && (!isset($str_tab) || $str_tab=="")) || ($ch=="Setup" && $ary_tab[$c]=="Setup" && (!isset($str_tab) || $str_tab=="")) || (($c==0 && !isset($str_tab)) && $ch=="") || $ary_tab[$c] == $str_tab)? "link_tab_slct" : "link_tab";
                        echo "<a href="Javascript:DisplayTab('" . $ary_tab[$c] . "','str_tab');" class=" . $class_tab . ">" . $ary_tab[$c] . "</a>";
                    }

                echo"</td>";
            echo"</tr>"; 
        echo"</table>";
      echo "</div>";
//echo $str_tab;
      if($str_tab != ""){

        switch($str_tab){
              case "Setup":
                  include("setup/setup.php");
                  break;
              case "Setup PostTest":
                  include("setup/setup.php");
                  break;
              case "Setup1":
                  include("setup1/setup.php");
                  break;
              case "Product Matrix":
                  include("productmatrix/productmatrix.php");
                  break;
              case "Socket Simulator":
                   // include("simulator/simulator.php");
                  include("simulator/Socket_simulator.php");
                  break;
             // case "Matrix Add":
               //   include("addmatrix/addmatrix.php");
              //    break;
              case "AVI Matrix Add":
                  include("addAVImatrix/addmatrix.php");
                  break;

          }
      }
      else {

        if ($ch=="ProductMatrix") {
            include("productmatrix/productmatrix.php");
          }
          else if($ch=="SocketSimulator"){
              // include("simulator/simulator.php");
              include("simulator/Socket_simulator.php");
          }
        else if($ch=="AVIMatrixAdd"){
              include("addAVImatrix/addmatrix.php");
          }
          else if($ch=="Setup"){
              include("setup/setup.php");
          }
          else if($ch=="SetupPost6E"){
              include("setup/setup.php");
          }
          else{
              include("setup/setup.php");
          }
      }

      //common
      echo "<input type="hidden" name="str_tab" value="" . $str_tab . "">";
      echo "<input type="hidden" name="winwidth" value="" . $winwidth . "">";
      echo "<input type="hidden" name="username" value="" . $loginname . "">";

    echo "</form>";
    flush();
    mysqli_close($conn);
    
  echo "</body>";
echo "</html>";
?>

Above codes are index.php codes.

var winplanproducttoentity = '';
var winupdateauto = '';
var winupdatebytester = '';
var winupdatebyproduct = '';
var winupdatestatus = '';
var wintestlot = '';
var winassignlot = '';
var winshowlot = ''
var winchecksicom = '';

var w;
var winwidth = window.screen.width;
var div = new Array('outputdiv','setupdiv');
//var div = new Array('outputdiv','setupdiv','availdiv');

var reqHttp  = InitRequest();
var reqHttp1 = InitRequest();
var reqHttp2 = InitRequest();
var reqHttp3 = InitRequest();


function InitRequest()  {
    var request=null;

    try { 
        request=new XMLHttpRequest(); 
    } 
    catch (e)   {   
        try { 
            request=new ActiveXObject("Msxml2.XMLHTTP");    
        } 
        catch (e){ 
            request=new ActiveXObject("Microsoft.XMLHTTP"); 
        }
    }
    return request;
}

function AsynReqData(request,url,fn) {
    request.open("GET", url + '&sid=' + Date() + Math.random(), true);
  request.onreadystatechange = eval(fn);
  request.send(null);
}

function SynReqData(request,url) {      
    request.open("GET", url + '&sid=' + Date() + Math.random(), false); 
    request.send(null);
    return request.responseText;
} 

function DisplayTab(tabname,tabid) {
    document.getElementById(tabid).value = tabname;  // this is the $str_tab
    document.lotmgt.submit();
}

function OnLoad(ch,badgeno){
   
    var tab = document.lotmgt.str_tab.value; //  this is the $str_tab from DisplayTab function
    w = (winwidth < 1280)? 1280 : winwidth;
    
    if((tab=='' & ch=='') || tab=='Setup' || (ch=='Setup' & tab=='')) {  
    
    var p_1 = "checked";
    var T_0 = "checked";
    var zmiss = "checked";

        for(var i=0; i<div.length; i++) {    
            document.getElementById(div[i]).className = 'hide'; 
        }
    
        // var wd = (128*5) - 10;  
        var wd = (128*7.5) - 50;  
        var lf = 0;     
        document.getElementById('filterdiv').style.width = wd + 'px';
        document.getElementById('filterdiv').style.left = lf + 'px';

        wd = (128*5.5) - 80;
        lf = (128*5) - 10;      // lf = (128*7) - 20;   
        document.getElementById('waferdiv').style.width = wd + 'px';
        document.getElementById('waferdiv').style.left = lf + 'px';
        
//  AsynReqData(reqHttp,'setup/content_wafer.php?site=','UpdateWafer');
        AsynReqData(reqHttp1,'setup/content_filter.php?site=' + '' + '&badgeno=' + badgeno + '&p_1=' + p_1 + '&T_0=' + T_0 + '&zmiss=' + zmiss,'UpdateFilter');
    }
    
    else if (tab=='Product Matrix' || (ch=='ProductMatrix' & tab=='')){
        AsynReqData(reqHttp,'productmatrix/content_filter.php?area=','UpdatePMFilter');
    }
    // else if (tab=='Matrix Simulator' || (ch=='MatrixSimulator' & tab=='')){
    //  // AsynReqData(reqHttp,'simulator/content_filter.php?area=','UpdateSIMFilter');
    // }
    else if (tab=='Setup PostTest' || (ch=='SetupPostTest' & tab=='')){
        var p_1 = "checked";
        var T_0 = "checked";

        var wd = (128*9) - 50;  
        var lf = 0;     
        document.getElementById('filterdiv').style.width = wd + 'px';
        document.getElementById('filterdiv').style.left = lf + 'px';

        AsynReqData(reqHttp1,'setup/content_filter1.php?site=' + '' + '&badgeno=' + badgeno + '&p_1=' + p_1 + '&T_0=' + T_0,'UpdateFilter');
    }       
}

//shared functions
function ManagePopup(except){
    var mywin = new Array('winplanproducttoentity','winupdateauto','winupdatebytester','winupdatebyproduct','winupdatestatus','wintestlot','winassignlot','winshowlot','winchecksicom');

    for(var i=0; i<mywin.length; i++)   {   
        var win = window[mywin[i]];
        if (mywin[i] == except){
            if(!win.closed && win.location) win.focus();
        }
        else{
            if(!win.closed && win.location) win.close();            
        }
    }   
}

function PlanProductToEntity(product,type){
    var w = 300;
    var h = 600;
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;     
    var winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no';
    
    ManagePopup('winplanproducttoentity');
    winplanproducttoentity = this.open('../lotmgt/wip/pop_assignproduct.php?product=' + product + '&type=' + type, 'winplanproducttoentity', winprops); 
}

Above codes are Javascript codes. Error says in Javascript and How to fix that?

Advertisement

Answer

The error occurs in the JS code and is due to the HTML generated in PHP which is missing an id attribute.

You seem to get the error here: document.getElementById(tabid).value = tabname; because document.getElementById(tabid) is null.

When it looks for the element with id str_tab it doesn’t find it. The only element in the HTML which could be the desired one has the attribute name="str_tab" and it’s your hidden field. You have to add the missing id="str_tab" attribute to this hidden field.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement