Advanced Search

Results 1 to 1 of 1

Thread: problem in popup page with document.getElementById

  1. #1
    Join Date
    Jul 2010
    Posts
    228
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Default problem in popup page with document.getElementById

    Hi!
    Good day!
    I have php file called: fab_spv_reports.php with a textbox : section_name and in that section name I have javascript function that display a table of process name/compound type with designated output and reject textboxes and it came from get_fab_spv_process_reject_list.php. On that textboxes when I click it has a pop up will displayed.
    When running the table page by itself (get_fab_spv_process_reject_list.php), the popup works fine, but when the table is loaded into into the main page (fab_spv_reports.php) as an object, the popup doesn't work.

    here is my code:
    fab_spv_reports.php
    Code:
    <?php
     session_start();
     include('connection.php');
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <script type="text/javascript" src="jquery.js"></script>
    <script type='text/javascript' src='jquery.autocomplete.js'></script>
    <link rel="stylesheet" type="text/css" href="jquery.autocomplete.css" />
    
    <script type="text/javascript">
    $().ready(function() {
        $("#section_name").autocomplete("get_section_list.php", {
           width: 205,
            matchContains: true,
            mustMatch: true,
            selectFirst: false
        });
        
        $("#section_name").result(function(event, data, formatted) {
            $("#section_id").val(data[1]);
        });  
         
    });
    function AJAX(){
            var xmlHttp;
            try{
                xmlHttp=new XMLHttpRequest();
                return xmlHttp;
                }
            catch (e){
                try{
                    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
                    return xmlHttp;
                    }
                catch (e){
                    try{
                        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                        return xmlHttp;
                        }
                    catch (e){
                        alert("Your browser does not support AJAX!");
                        return false;
                        }
                    }
                }
            }
    
    function getmat()
            {
                divid = "op_output_fieldset";
                var url = "get_fab_spv_process_reject_list.php";
                var str = "id=" + document.getElementById("section_name").value;
                var xmlHttp = AJAX();
                xmlHttp.onreadystatechange =  function(){
                if(xmlHttp.readyState > 0 && xmlHttp.readyState < 4){
                    }
                if (xmlHttp.readyState == 4) {
                    if (xmlHttp.status == 200) {
                        var jsonart = xmlHttp.responseText;
                        document.getElementById(divid).innerHTML = jsonart;
                        }
                    }
                }
                xmlHttp.open("POST", url, true);
                xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                xmlHttp.setRequestHeader("Content-length", str.length);
                xmlHttp.setRequestHeader("Connection", "close");
                xmlHttp.send(str);
            }
    </script>
    </head>
    <body onload=document.getElementById("section_name").focus();>
    <form name="operator_report" action="<?php echo $PHP_SELF; ?>" method="post" autocomplete="off">
    <div id="operators_report">
    <fieldset>
    <legend><h1>Supervisor's Shift Report</h1></legend>
    <table>
    <tr>
    <td>Section:</td>
    <td><input type="text" name="section_name" id="section_name" value="<?php echo $section_name; ?>" size="30" onkeydown="jumpnext('supervisor');getmat();"></td>
    <td>Supervisor:</td>
    <td><input type="text" name="supervisor" id="supervisor" value="<?php echo $supervisor; ?>" size="30" onkeydown="jumpnext('process_date');"></td>
    </tr>
    </table>
    </fieldset>
    </div>
    <input type="hidden" name="section_id" id="section_id" value="" />
    <div id="op_output_fieldset">
    </div>
    </form>
    </body>
    </html>
    get_fab_spv_process_reject_list.php
    Code:
    <?php
    ob_start();	 
    session_start();
    include "connection.php";
    
    //$section_name = 'Compounding';
    $section_name = $_POST["id"];
    if(isset($section_name))
    {  
        $display = "";
       $display .= "<div id='spv_fieldset'>"; 
       $display .=  "<fieldset>";
       $display .= "<legend style='font-size:36px;'> Supervisor's Output and Reject</legend>";
       $display .= "<table>";
       
       $display .= "<tr>";
       $display .= "<th>Process</th>";
    
        $sql = "select p.process_name, p.process_id FROM process_list AS p JOIN section_list AS s ON (p.section_id = s.section_id)
        where s.section_name LIKE '%" .$section_name. "%'";
        $rsd = mysql_query($sql);
        while($rs = mysql_fetch_assoc($rsd)) {
            $process_name[] = $rs['process_name'];
            $process_id[] = $rs['process_id'];
        }
        
        if(!isset($process_name) || isset($process_name) && empty($process_name)){
            $display .= "";
        }else{   
            foreach ($process_name as $k => $process_name_v){
    		$process_id_vv = $process_id[$k];   
                $display .= "<th style='border:none;' colspan='2'>
    			<input type='hidden' name='process_id[]' value='$process_id_vv' style='border:none;background-color: transparent;text-align:center; font-weight: bold;' size='15' />
    			<input type='text' name='process_name[]' value='$process_name_v' style='border:none;background-color: transparent;text-align:center;color: #fff; font-weight: bold;' size='15' />
    			</th>";
            }
            
            foreach ($process_id as $process_id_vv){   
               // $display .= "<input type='hidden' name='process_id[]' value='$process_id_vv' style='border:none;background-color: transparent;text-align:center; font-weight: bold;' size='15' />";
            }
            $display .= "</tr>";  
        } 
       $display .= "<tr>";
       $display .= "<th>Compound</th>";
       foreach($process_id AS $process_ii) {
       $display .= "<th>Output</th>";
       $display .= "<th>Reject</th>";
       }
        $sql_comp = "SELECT compound_id, compound_type FROM compound_list ORDER BY compound_type ASC";
        $res = mysql_query($sql_comp);
    
        if(mysql_num_rows($res)){
            
            while($comp = mysql_fetch_assoc($res)){    
            
            $compound_type = $comp['compound_type'];
            $compound_id   = $comp['compound_id'];   
                
            $display .= "<tr>";
    
                $display .= "<td style='border:none;'>
                <input type='text' name='compound_type[]' value='$compound_type' style='border:none;' size='10' />
                <input type='hidden' name='compound_id[]' value='$compound_id' />
                </td>";
                foreach($process_id AS $process_i) {
                  //----in this textboxes display the popup window using onkeyup to input the total then after click the submit button from popup the total will be displayed on the textbox.  
                  $output_value = (isset($_SESSION['output']) && array_key_exists($process_i,$_SESSION['output']) && array_key_exists($compound_id,$_SESSION['output'][$process_i]) ? "{$_SESSION['output'][$process_i][$compound_id]}" :'');
    			  $display .= "<td style='border:none;'>
    			  <input type='hidden' name='output.$process_i.$compound_id' value='output.$process_i.$compound_id' id=\"output.$process_i.$compound_id\" />
    			  <input type='text' name='output[$compound_id][$process_i][]' value='$output_value' size='7' id=\"o.$process_i.$compound_id\"  onclick=\"var val = document.getElementById('output.$process_i.$compound_id').value; child_open(val);return false\" />
                 
    			  </td>"; 
                  $reject_value = (isset($_SESSION['reject']) && array_key_exists($process_i,$_SESSION['reject']) && array_key_exists($compound_id,$_SESSION['reject'][$process_i]) ? "{$_SESSION['reject'][$process_i][$compound_id]}" :'');
                  $display .= "<td style='border:none;'>
    			  <input type='hidden' name='reject.$process_i.$compound_id' value='reject.$process_i.$compound_id' id=\"reject.$process_i.$compound_id\" />
    			  <input type='text' name='reject[$compound_id][$process_i][]' value='$reject_value' size='7' id=\"r.$process_i.$compound_id\"  onclick=\"var val = document.getElementById('reject.$process_i.$compound_id').value; child_open(val);return false\" />
    			  </td>";
              
                }
                
                $display .= "</tr>";
            }
        }
    }
     $display .= "</table>
    </fieldset>
    </div>"; 
    ?>
    
    <head>
    <title> Supervisor's Output and Reject</title>
    <script type="text/javascript">
    
        var popupWindow=null;
    
        function child_open(val){
            popupWindow =window.open('popup.php' + "?val=" + val,"_blank","directories=no, status=no, menubar=no, scrollbars=yes, resizable=no,width=600, height=280,top=200,left=200");
        }
    
        function parent_disable() {
            if(popupWindow && !popupWindow.closed)
                popupWindow.focus();
        }
    </script>
    </head>
    <body>
    <?php
        if(isset($display)){
            echo "$display";
        }	
    ?>
    </body>
    On testing.run the fab_spv_reports.php try to type Com on section then there is a auto suggest displayed, choose Compounding useing arrow down key then press enter key.

    Try to click in any textboxes on supervisors output and reject you will get an object expected error.

    But when you run directly using get_fav_spv_process_reject_list the popup will display after click on any textboxes.

    I attached the sample screenshot and database
    I hope somebody can help me on this.

    Thank you so much.
    Attached Files Attached Files

Similar Threads

  1. document.getElementById
    By locbtran in forum JavaScript
    Replies: 5
    Last Post: 05-28-2012, 09:10 AM
  2. document.getElementById from another page?
    By akdream in forum JavaScript
    Replies: 2
    Last Post: 02-11-2012, 10:42 PM
  3. RSS displaybox: document.getElementById bug in IE8?
    By flapane in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 04-06-2011, 11:30 AM
  4. document.getElementById problem
    By yoyoyo in forum JavaScript
    Replies: 5
    Last Post: 12-23-2008, 06:00 AM
  5. document.getElementById issue
    By svoirin in forum JavaScript
    Replies: 1
    Last Post: 04-12-2006, 10:09 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •