SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    658
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    getting undefined using $_GET function

    Hi..

    I encountered problem in using $_GET to get the DATE_PROCESS.

    here is my code:

    Code:
    <script>
    function editloan(){
    
    var dateprocess = document.getElementById('dateprocess').value; 
    
    alert(dateprocess);
    window.location = "SSSLoan.php?dateprocess="+dateprocess;
    }
    </script>
    Code:
    <div id="searchname">
    <form>
    <p class="serif"><b>Search Lastname:</b></p>
    <input type="text" name="ssssearch" size="20" onkeyup="fetchsuggest(this.value);">
    <div>
    <hr />
    <ul id="suggest" style="overflow:auto; height:380px; width:auto;">
    {section name=co_emp loop=$personalAll}
    <li><a href="SSSgetdata.php?queryEmpID={$personalAll[co_emp].EMP_ID}">{$personalAll[co_emp].FULLNAME}</a></li>  
    <hr />
    {sectionelse}
    <li>No records found</li>
    {/section}
    </ul>
    </div>
    </div>  
    <div id="loanformmain">
    <input type="button" name="sssbtn" value="SSS" onclick="loanFrm()">
    <input type="button" name="hdmfbtn" value="HDMF" onClick="hdmfloanFrm()">
    <input type="button" name="UTbtn" value="Union Dues/Trust Fund" onclick="utloanFrm()">
    </div>
    <div id="sssloan">
    <fieldset>
    <legend>SSS Loan</legend>
    <p class="serif">
    <label id="SSSLabel">SSS ID</label><label id="EMPIDLabel">EMP ID</label><label id="NAMELabel">NAME</label><label id="LOANLabel">LOAN</label><label id="AMORLabel">DEDUCTION</label>
    <input type="text" name="SSS" value="{$sss}" size="8" style="background: #e2e2e2" readonly="readonly">
    <input type="text" name="EMP_NO" value="{$empno}" size="8" style="background: #e2e2e2" readonly="readonly">
    <input type="text" name="NAME" value="{$fullname}" style="background: #e2e2e2" readonly="readonly" size="35">
    <input type="text" name="LOAN" value="{$LOAN}" size="9">
    <input type="text" name="AMOR" value="{$AMOR}" size="9"> 
    <input type="button" name="add" value="ADD" onclick="SSSAdd()">
    <input type="hidden" name="dateprocess" value="{$dateprocess">
    </p>
    </legend>
    
    </fieldset>
    <div style="overflow:auto; height:300px; width:auto;">
    <p>
    <table border="1" class="stat"> 
    <tr>
    <td colspan="4" style="text-align:center">SSS ID</td>
    <td colspan="4" style="text-align:center">EMP ID</td>
    <td colspan="15" style="text-align:center">NAME</td>
    <td colspan="4" style="text-align:center">LOAN</td>
    <td colspan="4" style="text-align:center">DEDUCTION</td>
    <td colspan="4" style="text-align:center">DATE PROCESS</td>
     
    </tr>
    {section name=att loop=$getsss} 
      <tr>
        <td colspan="4" style="background: #e2e2e2" readonly="readonly">{$getsss[att].SSS}</td>
       <td colspan="4" style="background: #e2e2e2" readonly="readonly">{$getsss[att].EMP_NO}</td>   
        <td colspan="15" style="background: #e2e2e2" readonly="readonly">{$getsss[att].FULLNAME}</td>   
        <td colspan="4" style="background: #e2e2e2" readonly="readonly">{$getsss[att].SSSLoan}</td>
        <td colspan="4" style="background: #e2e2e2" readonly="readonly">{$getsss[att].SSSAmor}</td>
        <td colspan="4" style="background: #e2e2e2" readonly="readonly" id="dateprocess" onclick="editloan('{$getsss[att].DATE_PROCESS}')">{$getsss[att].DATE_PROCESS}</td>
      </tr>
    {sectionelse}   
      <tr><td colspan="1">No DATA</td></tr>
    {/section}
      
    </table>
    <table border="1"> 
    <tr>
    <td colspan="4" style="text-align:center"><b>TOTAL:</b></td>  <td colspan="5" style="background: #e2e2e2" readonly="readonly">{$Total_Loan}</td>  
    </tr>
    </table> 
    </p>
    </form>
    </div>
    </div>
    Code:
    <?php
    include 'config.php';
    
    $currentEmpID = $_SESSION['empID'];
    
    $sql = "SELECT EMP_ID, CONCAT(LNAME, ', ',  FNAME, ' ', MI, '.') AS FULLNAME, SSS, HDMF, TIN FROM PERSONAL WHERE EMP_ID='$currentEmpID'";
    $recPersonal = $conn->Execute($sql);
    
    if (!$recPersonal) {
        print $conn->ErrorMsg();
    }
    
    if (!$recPersonal->BOF) {
        $recPersonal->MoveFirst();
    }
    
    $sss                = trim($recPersonal->fields['SSS']);          
    $hdmf               = trim($recPersonal->fields['HDMF']);
    $tin                = trim($recPersonal->fields['TIN']);
    
    $smarty->assign('sss', $sss);
    
    
    $sql = "SELECT EMP_ID, CONCAT(LNAME, ', ' , FNAME, ' ', MI) AS FULLNAME FROM PERSONAL ORDER BY LNAME ASC";
    $recPersonalNav = $conn->GetAll($sql);
    $smarty->assign('personalAll', $recPersonalNav);
    // ========================================================================================================================
    
    $sql = "SELECT em.EMP_NO, p.EMP_ID, CONCAT(LNAME, ', ',  FNAME, ' ', MI, '.') AS FULLNAME FROM PERSONAL p, EMPLOYMENT em  WHERE p.EMP_ID='$currentEmpID' AND em.EMP_ID = '$currentEmpID'"; 
       
    $recPersonalHead = $conn->Execute($sql);
    $fullName = $recPersonalHead->fields["FULLNAME"];
    $empno = $recPersonalHead->fields["EMP_NO"];
    
    $smarty->assign('empid', $currentEmpID);
    $smarty->assign('fullname', $fullName);
    $smarty->assign('empno', $empno);
    
    //===============================SELECT SSSLoan===================================
    $dateprocess = $_GET['dateprocess']; 
    
    $sql = "SELECT s.EMP_NO, s.SSSLoan, s.SSSAmor, s.DATE_PROCESS FROM $PAYROLL.sssloan s, $ADODB_DB.employment em WHERE em.EMP_NO= s.EMP_NO AND s.DATE_PROCESS = '$dateprocess'"; 
    $rsloan = $conn2->Execute($sql);
    
    $LOAN = trim($rsloan->fields['SSSLoan']);
    $AMOR = trim($rsloan->fields['SSSAmor']);
    
    $dateprocess = $rsloan->fields['DATE_PROCESS'] ;
    
    $smarty->assign('LOAN', $LOAN);
    $smarty->assign('AMOR', $AMOR);
    $smarty->assign('dateprocess', $dateprocess);
    
    //============================SELECT ALL DATA FOR SSSLOAN==========================
    $sql = "SELECT s.EMP_NO, em.EMP_ID, p.SSS, CONCAT(LNAME, ', ',  FNAME, ' ', MI, '.') AS FULLNAME, s.SSSLoan, s.SSSAmor, s.DATE_PROCESS FROM $ADODB_DB.PERSONAL p, $ADODB_DB.employment em, $PAYROLL.sssloan s WHERE s.EMP_NO = em.EMP_NO AND p.EMP_ID = '$currentEmpID' AND em.EMP_ID = '$currentEmpID'";
    
    $rs = $conn2->GetAll($sql);
    
    $smarty->assign('getsss', $rs); 
    
    $sql = "SELECT s.EMP_NO, SUM(SSSAmor) AS Total_Loan FROM $PAYROLL.sssloan s, $ADODB_DB.employment em WHERE em.EMP_NO = s.EMP_NO AND em.EMP_ID = '$currentEmpID'" or die (mysql_error());
    $rsTotal = $conn2->Execute($sql);
    
    $Total_Loan = $rsTotal->fields['Total_Loan'];
    
    $smarty->assign('Total_Loan', $Total_Loan); 
    
    $smarty->display('header.tpl');
    $smarty->display('loanForm.tpl');
    $smarty->display('footer.tpl'); 
    exit();
    ?>
    when I click date in <td colspan="4" style="background: #e2e2e2" readonly="readonly" id="dateprocess" onclick="editloan('{$getsss[att].DATE_PROCESS}')">{$getsss[att].DATE_PROCESS}</td>

    it result no value...it did not get the value that I click

    Thank you in advance

  2. #2
    Non-Member Max Height's Avatar
    Join Date
    Dec 2011
    Posts
    303
    Mentioned
    6 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by newphpcoder View Post
    it result no value...it did not get the value that I click
    What is the "it" you are referring to and what error message(s) did you get?

  3. #3
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    658
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My error is undefined...

    I tried this code:

    Code:
    function editloan(){
    
    var dateprocess = document.getElementById('dateprocess').firstChild.nodeValue;
      
    alert(dateprocess);
    window.location = "SSSLoan.php?dateprocess="+dateprocess;
    
    }
    And i get the date but the problem is only the first date was displayed...

    i have dates:

    2011-12-18
    2011-12-20
    2011-12-28

    eventhough i click 2011-12-28 the date displayed is 2011-12-18

    i also tried this:

    Code:
    var dateprocess = document.getElementById('dateprocess').innerHTML;
    still the firstdate was displayed..

    Thank you

  4. #4
    Non-Member Max Height's Avatar
    Join Date
    Dec 2011
    Posts
    303
    Mentioned
    6 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by newphpcoder View Post
    My error is undefined...
    That makes no sense at all. How can an error itself be undefined? It is probably telling you some sort of variable or parameter is undefined

    Copy and paste the error message(s) that appears in your browser and post it.

    btw - you still haven't answered the first part of my query.
    What is the "it" you are referring to and what error message(s) did you get?

  5. #5
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    658
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i referred "it" as the dateprocess..


    now, I don't get an error, yet I only get the first date eventhough I click the last date.

    Thank you

  6. #6
    Non-Member Max Height's Avatar
    Join Date
    Dec 2011
    Posts
    303
    Mentioned
    6 Post(s)
    Tagged
    1 Thread(s)
    what part(s) of that code did you actually write?

  7. #7
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    658
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes,but this code was suggested to me:

    Code:
    var dateprocess = document.getElementById('dateprocess').firstChild.nodeValue;
    because in <td> has no value, so i need to used nodeValue...

    Thank you

  8. #8
    Non-Member Max Height's Avatar
    Join Date
    Dec 2011
    Posts
    303
    Mentioned
    6 Post(s)
    Tagged
    1 Thread(s)
    to check if dateprocess contains the correct value you can add alert(dateprocess) just below it.

    If it doesn't contain the expected value then you need to step back through your code line by line, checking values of variables to find the line of code causing the problem and then fix it.

  9. #9
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    658
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I already resolved it using this code:

    Code:
    function editloan(thedate){
    
    var dateprocess = thedate
    
    //alert(dateprocess);
    window.location = "SSSLoan.php?dateprocess="+dateprocess;
    }


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
  •