Welcome Guest, Not a member yet? Register   Sign In
Get ID from database when a specific td is clicked
#6

(This post was last modified: 01-05-2018, 11:06 AM by Wouter60.)

(01-05-2018, 03:45 AM)FARUKB13 Wrote: Thanks for all the replies. But Wouter, I want to get the Id in the url by clicking the checkbox. I tried it but it isn't really functioning like how I wanted. How do I make that?

First, give the checkbox a css class:
Code:
<td><input type="checkbox" class="toggle_url"></td>

Then, put the url (including the id!) between <span></span> tags and also give the span tag a css class:
PHP Code:
<td><span class="terugbel_url" style="display: none;"><a href="http://managementtool/index.php/Home/terugbel/<?= $row->id;?>"><?= $row->terugbellen;?></a></span></td> 

Initally, the url isn't visible at all. I assume there's no point in clicking the url if it doesn't have the row's id, right?

Finally, write jQuery code to display the span element if the checkbox is checked, or hide it if the checkbox is unchecked.
Code:
<script>
$(document).ready(function(){
  $('.toggle_url').click(function(){
     if ( $(this).is(':checked') ) {
       $(this).parent('tr').find('.terugbel_url').show();
    }
    else {
       $(this).parent('tr').find('.terugbel_url').hide();
    }
  });
})
</script>

Now, if you check the checkbox, the corresponding url with the id will show up.
Reply


Messages In This Thread
RE: Get ID from database when a specific td is clicked - by Wouter60 - 01-05-2018, 04:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB