• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
html tr onclick to call controller function

#1
I am using html php of codeiginter and javascript in my web site. Now I have records list in html table tr. If I click on the row, i want to trigger the action of the controller path to update db with passing record id on this row. Could you help me to instruct how to do?? Does it need ajax or any code??
Reply

#2
Hi

You can write something like below:

Code:
<table>
    <tr onClick="editData(<?php echo $row['id'];?>)"><td><?php echo $row['id'];?></td><td><?php echo $row['name'];?></td></tr>
</table>
<form name="frmEdit" id="frmEdit" action=<?php echo base_url();?>controller_name/action_name" method="post"/>
<input type="hidden" name="id" id="id" value="" />
</form>
<script>
function editData(id)
{
    $("#id").val(id);
    document.frmEdit.submit();    
}
</script>
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.