newphpbees Posted December 21, 2011 Share Posted December 21, 2011 Hi I have a queries to display data in my template file, and i encountered problem in onclick EMP_ID here is my query: <?php include 'config.php'; $currentEmpID = $_SESSION['empID']; $sql = "SELECT em.EMP_ID, s.EMP_NO, s.SSSLoan, s.SSSAmor FROM $PAYROLL.sssloan s, $ADODB_DB.employment em WHERE em.EMP_NO= s.EMP_NO AND em.EMP_ID = '$currentEmpID'"; $rsloan = $conn2->Execute($sql); $LOAN = trim($rsloan->fields['SSSLoan']); $AMOR = trim($rsloan->fields['SSSAmor']); $smarty->assign('LOAN', $LOAN); $smarty->assign('AMOR', $AMOR); $sql = "SELECT s.EMP_NO, p.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); ?> and here is the template code: // this data will change if the EMP_ID was click <input type="text" name="LOAN" value="{$LOAN}" size="9"> <input type="text" name="AMOR" value="{$AMOR}" size="9"> {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" onclick="changeEmployee1('{$getsss[att].EMP_ID}')">{$getsss[att].EMP_NO}</td> <!--<td colspan="4" style="background: #e2e2e2" readonly="readonly"><a href="SSSgetdata.php?queryEmpID={$getsss[att].EMP_ID}">{$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">{$getsss[att].DATE_PROCESS}</td> </tr> {sectionelse} <tr><td colspan="1">No DATA</td></tr> {/section} My problem is in onclick,the data loan and amor was not change when i click EMP_ID. Thank you Quote Link to comment https://forums.phpfreaks.com/topic/253585-problem-in-changing-data-using-onclick/ Share on other sites More sharing options...
m3bik Posted December 21, 2011 Share Posted December 21, 2011 What does your changeEmployee1 javascript function do, exactly? That appears to be what's called when the field is clicked, correct? Quote Link to comment https://forums.phpfreaks.com/topic/253585-problem-in-changing-data-using-onclick/#findComment-1299982 Share on other sites More sharing options...
newphpbees Posted December 21, 2011 Author Share Posted December 21, 2011 function changeEmployee1(queryID) { //alert(queryID); window.location = "SSSgetdata.php?queryEmpID=" + queryID; } <?php session_start(); $queryStr = trim($_GET["queryEmpID"]); $_SESSION['empID'] = $queryStr; session_write_close(); header("Location:SSSLoan.php"); exit(); ?> he gets the emp id...before it works but now that I change my query, it was not work.. Thank you Quote Link to comment https://forums.phpfreaks.com/topic/253585-problem-in-changing-data-using-onclick/#findComment-1299983 Share on other sites More sharing options...
newphpbees Posted December 21, 2011 Author Share Posted December 21, 2011 I can't figured out why now the changing of data was not work when i click EMP_NO Thank you Quote Link to comment https://forums.phpfreaks.com/topic/253585-problem-in-changing-data-using-onclick/#findComment-1300021 Share on other sites More sharing options...
newphpbees Posted December 21, 2011 Author Share Posted December 21, 2011 I tried to check if the EMP_ID is has data. {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" onclick="changeEmployee1('{$getsss[att].EMP_ID}')">{$getsss[att].EMP_NO}</td> <!--<td colspan="4" style="background: #e2e2e2" readonly="readonly"><a href="SSSgetdata.php?queryEmpID={$getsss[att].EMP_ID}">{$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">{$getsss[att].DATE_PROCESS}</td> {$getsss[att].EMP_ID} </tr> {sectionelse} <tr><td colspan="1">No DATA</td></tr> {/section} As you can i try to displayed: {$getsss[att].EMP_ID} and i found out it produce 3 EMP_ID: 000009 000009 000009 because i have 3 data from that employee.. when i click one data from the list the EMP_ID still three Thank you Quote Link to comment https://forums.phpfreaks.com/topic/253585-problem-in-changing-data-using-onclick/#findComment-1300023 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.