Jump to content

getting undefined using $_GET function


newphpbees

Recommended Posts

Hi..

 

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

 

here is my code:

 

<script>
function editloan(){

var dateprocess = document.getElementById('dateprocess').value; 

alert(dateprocess);
window.location = "SSSLoan.php?dateprocess="+dateprocess;
}
</script>

 

<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>      

 

<?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

Link to comment
Share on other sites

Without reading into this too much, it looks like your putting {$getsss[att].DATE_PROCESS} in non string blocks. (It appears you're using direct HTML output instead.)

 

Change it to <?php echo $getsss[att].DATE_PROCESS;?> Or whatever your variable name is. I'm assuming DATE_PROCESS is a constant defined in your script?

 

Second issue is that you are trying to pull a property "value" from a table cell. You have to pull values from an input statement, since value is a property of that tag. I suppose though, that you might be able to add a "value" attribute to the the td cell, but I don't know if that would work. Either way, its not recommended to do that. Just put an input box inside of the cell.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.