Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Posts
    712
    Thanks
    165
    Thanked 0 Times in 0 Posts

    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
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    This is more of a javascript problem than a php one. It doesn't get the value because it is a td element not a form input. A td element does not have a "value" property. Try this instead
    Code:
    var dateprocess = document.getElementById('dateprocess').firstChild.nodeValue;
    Last edited by _Aerospace_Eng_; 01-03-2012 at 01:42 AM.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,091
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Quote Originally Posted by _Aerospace_Eng_ View Post
    This is more of a javascript problem than a php one.
    Careful AE, I can't remember why but I added this user to my ignore list ages ago. Only reason I still reply sometimes is because the main list still shows this persons topics (yet when I click into it, the forum hides the opening post )
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • #4
    Regular Coder
    Join Date
    Aug 2010
    Posts
    712
    Thanks
    165
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by _Aerospace_Eng_ View Post
    This is more of a javascript problem than a php one. It doesn't get the value because it is a td element not a form input. A td element does not have a "value" property. Try this instead
    Code:
    var dateprocess = document.getElementById('dateprocess').firstChild.nodeValue;
    I tried this, but the problem is only the first date was get.

    Thank you...

    i have date:

    2011-12-18
    2011-12-20
    2011-12-28
    when i click 2011-12-28 the displayed date is 2011-12-18

    Thank you

  • #5
    Regular Coder
    Join Date
    Aug 2010
    Posts
    712
    Thanks
    165
    Thanked 0 Times in 0 Posts
    i also tried this:

    Code:
    var dateprocess = document.getElementById('dateprocess').innerHTML;
    but still the first date only was displayed even i click the last date...:confused:

    Thank you

  • #6
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Right because you are only supposed to have one element with id="dateprocess", not multiple like you have. Just change this
    Code:
    function editloan(){
    
    var dateprocess = document.getElementById('dateprocess').value; 
    
    alert(dateprocess);
    window.location = "SSSLoan.php?dateprocess="+dateprocess;
    }
    to this
    Code:
    function editloan(thedate){
    
    var dateprocess = thedate;
    
    alert(dateprocess);
    window.location = "SSSLoan.php?dateprocess="+dateprocess;
    }
    So again this is a javascript problem not a php one.
    Last edited by _Aerospace_Eng_; 01-03-2012 at 03:34 AM.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • Users who have thanked _Aerospace_Eng_ for this post:

    newphpcoder (01-03-2012)

  • #7
    Regular Coder
    Join Date
    Aug 2010
    Posts
    712
    Thanks
    165
    Thanked 0 Times in 0 Posts
    Thank you...it works...can you explain me the used of

    thedate?


    Thank you

  • #8
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,273
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Moving to JS forum...
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #9
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    In your output you had onclick="editloan(some date here)", so to use document.getElementById you had to pass in the ID of the current element. You weren't doing that. You were passing in the date yet your function didn't accept any arguments. thedate is an argument to your editloan function although you should probably be passing in the ID of the loan and not the date. What if you have more than one loan on the same date.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • Users who have thanked _Aerospace_Eng_ for this post:

    newphpcoder (01-03-2012)


  •  

    Posting Permissions

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