CodeIgniter Forums
how to make the table rows into links? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: how to make the table rows into links? (/showthread.php?tid=24218)



how to make the table rows into links? - El Forum - 11-03-2009

[eluser]paigenotfound[/eluser]
hi again, im having trouble making my table rows into links. the table will be populated with first name and last name. and click on the first name and last name will bring them to their corresponding user profile.

is there a way to make the rows wihtin my table into clickable links in ci? i tried the js onClick event on the <tr> tag but cant seem to make it work. wrapping the whole row with <a></a> wont do also. hope someone can help me here. thank you in advance.


how to make the table rows into links? - El Forum - 11-03-2009

[eluser]n0xie[/eluser]
Wrap the inner content of the TD in a <a > ?


how to make the table rows into links? - El Forum - 11-03-2009

[eluser]paigenotfound[/eluser]
i mean something like this

Code:
echo '<a href='.base_url().'>cid.'>';
echo '<tr>';
echo '<td>';
echo ucwords($row->lname).',' ;
echo '</a>';
echo '</td>';
echo '<td>';
echo ucwords($row->fname);
echo '</td>';
echo '</tr>';
echo '</a>';



how to make the table rows into links? - El Forum - 11-03-2009

[eluser]rogierb[/eluser]
ehhh... right... You gave yourself the answer

<b>Edit</b> CI keeps f-ing up the code I post....
Code:
a href=base_url().memberprofile/.$row->user_id



how to make the table rows into links? - El Forum - 11-03-2009

[eluser]John_Betong[/eluser]
[quote author="paigenotfound" date="1257276904"]i mean something like this

Code:
echo '<a href='.base_url().'>cid.'>';
echo '<tr>';
echo '<td>';
echo ucwords($row->lname).',' ;
echo '</a>';
echo '</td>';
echo '<td>';
echo ucwords($row->fname);
echo '</td>';
echo '</tr>';
echo '</a>';
[/quote]
&nbsp;
&nbsp;
Why use tables? Try this: &nbsp; this &nbsp; instead.
&nbsp;
&nbsp;
&nbsp;


how to make the table rows into links? - El Forum - 11-03-2009

[eluser]paigenotfound[/eluser]
the reason why i use table is because the contents will be populated by a db query which will list all users and some of their info.

the list will become quite large so i need to properly format it using a table. what i would like to achieve is to make the whole table row a clickable link which will forward to the corresponding user profile.

thank you all for your time.


how to make the table rows into links? - El Forum - 11-03-2009

[eluser]Colin Williams[/eluser]
Not so sure a whole table row can be hyperlinked, but I may be wrong. The other option is to do some javascript that drills <tr> clicks down to the first child <a>

Code:
// jQuery
$('.data tr').click(function(){$('a', this).eq(0).click()});

Some browsers might not fire the click event for <tr> though, so you might need to get even trickier, using <td> clicks instead (td > parent tr > first a)


how to make the table rows into links? - El Forum - 11-03-2009

[eluser]pistolPete[/eluser]
Have a look at Clickable table rows using Jquery.


how to make the table rows into links? - El Forum - 11-03-2009

[eluser]John_Betong[/eluser]
&nbsp;
Here we go, version: 002 with just CSS:

http://localhost/downloads/codeigniter/css_tables/index_ver_02.php
&nbsp;
&nbsp;
&nbsp;