problem in changing data using onclick

Discussion in 'PHP' started by newphpcoder, Dec 20, 2011.

  1. #1
    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); 
    ?>
    
    
    Code (markup):
    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} 
    
    Code (markup):
    My problem is in onclick,the data loan and amor was not change when i click EMP_ID.

    Thank you
     
    newphpcoder, Dec 20, 2011 IP
  2. Jaxo

    Jaxo Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #2
    You can't use onclick(), or any client-side event in PHP. It's all JavaScript, which is an entirely new beast to tame when you're making websites.
     
    Jaxo, Dec 31, 2011 IP
  3. Alex Roxon

    Alex Roxon Active Member

    Messages:
    424
    Likes Received:
    11
    Best Answers:
    7
    Trophy Points:
    80
    #3
    You can, you just need to fire an ajax call. Is that what you're doing?
     
    Alex Roxon, Jan 1, 2012 IP
  4. newphpcoder

    newphpcoder Greenhorn

    Messages:
    57
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #4
    Yes... I used ajax...here is my javascript:
    function changeEmployee1(queryID) {window.location = "SSSgetdata.php?queryEmpID=" + queryID;}
    Code (markup):
    my problem is queryID is the same because its only one employee.Thank you
     
    newphpcoder, Jan 2, 2012 IP