Bonjour,

Je voudrais savoir comment faire pour récupérer l'id de la ligne sélectionné dans un tableau.

Prenons ce tableau :

<table id="exampletoto" class="display" cellspacing="0" width="100%" height:"300px";>
        <thead>
            <tr>
                <th>Author</th>
                <th>Organization</th>
                <th>Nb docs</th>
            </tr>
        </thead>

        <tbody>
            <tr>
                <td id="author1">Tiger Nixon</td>
                <td>System Architect</td>
                <td>2</td>
            </tr>
            <tr>
                <td id="author2">Garrett Winters</td>
                <td>Accountant</td>
                <td>8</td>
            </tr>
            <tr>
                <td id="author3">Ashton Cox</td>
                <td>Junior Technical Author</td>
                <td>8</td>
            </tr>
            <tr>
                <td id="author4">Cedric Kelly</td>
                <td>Senior Javascript Developer</td>
                <td>99</td>
            </tr>
            <tr>
                <td id="author5">Airi Satou</td>
                <td>Accountant</td>
                <td>89</td>
            </tr>
            <tr>
                <td id="author6">Brielle Williamson</td>
                <td>Integration Specialist</td>
                <td>4</td>
            </tr>
            <tr>
                <td id="author7">Herrod Chandler</td>
                <td>Sales Assistant</td>
                <td>3</td>
             </tr>
            <tr>
                <td id="author8">Rhona Davidson</td>
                <td>Integration Specialist</td>
                <td>68</td>
            </tr>
            <tr>
                <td id="author9">Colleen Hurst</td>
                <td>Javascript Developer</td>
                <td>2</td>
            </tr>
            <tr>
                <td id="author10">Sonya Frost</td>
                <td>Software Engineer</td>
                <td>758</td>
            </tr>
            <tr>
                <td id="author11">Jena Gaines</td>
                <td>Office Manager</td>
                <td>3</td>
             </tr>
            <tr>
                <td id="author12">Quinn Flynn</td>
                <td>Support Lead</td>
                <td>65</td>
            </tr>
            <tr>
                <td id="author13">Charde Marshall</td>
                <td>Regional Director</td>
                <td>856</td>
            </tr>
            <tr>
                <td id="author14">Haley Kennedy</td>
                <td>Senior Marketing Designer</td>
                <td>8</td>
             </tr>
            <tr>
                <td id="author15">Tatyana Fitzpatrick</td>
                <td>Regional Director</td>
                <td>86</td>
            </tr>
            <tr>
                <td id="author16">Michael Silva</td>
                <td>Marketing Designer</td>
                <td>3</td>
            </tr>
            <tr>
                <td id="author17">Paul Byrd</td>
                <td>Chief Financial Officer (CFO)</td>
                <td>99</td>
            </tr>
            <tr>
                <td id="author18">Gloria Little</td>
                <td>Systems Administrator</td>
                <td>79</td>
            </tr>
            <tr>
                <td id="author19">Bradley Greer</td>
                <td>Software Engineer</td>
                <td>5</td>
            </tr>
            <tr>
                <td id="author20">Dai Rios</td>
                <td>Personnel Lead</td>
                <td>1</td>
            </tr>
            <tr>
                <td id="author21">Jenette Caldwell</td>
                <td>Development Lead</td>
                <td>658</td>
             </tr>
            <tr>
                <td id="author22">Yuri Berry</td>
                <td>Chief Marketing Officer (CMO)</td>
                <td>68</td>
            </tr>
            <tr>
                <td id="author23">Caesar Vance</td>
                <td>Pre-Sales Support</td>
                <td>55</td>
            </tr>
            <tr>
                <td id="author24">Doris Wilder</td>
                <td>Sales Assistant</td>
                <td>5</td>
            </tr>
            <tr>
                <td id="author25">Angelica Ramos</td>
                <td>Chief Executive Officer (CEO)</td>
                <td>44</td>
            </tr>
            <tr>
                <td id="author26">Gavin Joyce</td>
                <td>Developer</td>
                <td>77</td>
            </tr>
            <tr>
                <td id="author27">Jennifer Chang</td>
                <td>Regional Director</td>
                <td>7</td>
            </tr>
            <tr>
                <td id="author28">Brenden Wagner</td>
                <td>Software Engineer</td>
                <td>2</td>
            </tr>
            <tr>
                <td id="author29">Fiona Green</td>
                <td>Chief Operating Officer (COO)</td>
                <td>564</td>
            </tr>
            <tr>
                <td id="author30">Shou Itou</td>
                <td>Regional Marketing</td>
                <td>32</td>
            </tr>
            <tr>
                <td id="author31">Michelle House</td>
                <td>Integration Specialist</td>
                <td>5</td>
            </tr>
            <tr>
                <td id="author32">Suki Burks</td>
                <td>Developer</td>
                <td>168</td>
            </tr>
            <tr>
                <td id="author33">Prescott Bartlett</td>
                <td>Technical Author</td>
                <td>77</td>
            </tr>
            <tr>
                <td id="author34">Gavin Cortez</td>
                <td>Team Leader</td>
                <td>54</td>
            </tr>
            <tr>
                <td id="author35">Martena Mccray</td>
                <td>Post-Sales support</td>
                <td>8</td>
            </tr>
            <tr>
                <td id="author36">Unity Butler</td>
                <td>Marketing Designer</td>
                <td>89</td>
            </tr>
            <tr>
                <td id="author37">Howard Hatfield</td>
                <td>Office Manager</td>
                <td>96</td>
            </tr>
            <tr>
                <td id="author38">Hope Fuentes</td>
                <td>Secretary</td>
                <td>75</td>
            </tr>
            <tr>
                <td id="author39">Vivian Harrell</td>
                <td>Financial Controller</td>
                <td>56</td>
            </tr>
            <tr>
                <td id="author40">Timothy Mooney</td>
                <td>Office Manager</td>
                <td>25</td>
            </tr>
            <tr>
                <td id="author41">Jackson Bradshaw</td>
                <td>Director</td>
                <td>89</td>
            </tr>
            <tr>
                <td id="author42">Olivia Liang</td>
                <td>Support Engineer</td>
                <td>6</td>
            </tr>
            <tr>
                <td id="author43">Bruno Nash</td>
                <td>Software Engineer</td>
                <td>2</td>
            </tr>
            <tr>
                <td id="author44">Sakura Yamamoto</td>
                <td>Support Engineer</td>
                <td>8</td>
            </tr>
            <tr>
                <td id="author45">Thor Walton</td>
                <td>Developer</td>
                <td>3</td>
            </tr>
            <tr>
                <td id="author46">Finn Camacho</td>
                <td>Support Engineer</td>
                <td>478</td>
            </tr>
            <tr>
                <td id="author47">Serge Baldwin</td>
                <td>Data Coordinator</td>
                <td>857</td>
            </tr>
            <tr>
                <td id="author48">Zenaida Frank</td>
                <td>Software Engineer</td>
                <td>1</td>
            </tr>
            <tr>
                <td id="author49">Zorita Serrano</td>
                <td>Software Engineer</td>
                <td>65</td>
            </tr>
            <tr>
                <td id="author50">Jennifer Acosta</td>
                <td>Junior Javascript Developer</td>
                <td>2</td>
            </tr>
            <tr>
                <td id="author51">Cara Stevens</td>
                <td>Sales Assistant</td>
                <td>23</td>
            </tr>
            <tr>
                <td id="author52">Hermione Butler</td>
                <td>Regional Director</td>
                <td>53</td>
            </tr>
            <tr>
                <td id="author53">Lael Greer</td>
                <td>Systems Administrator</td>
                <td>41</td>
            </tr>
            <tr>
                <td id="author54">Jonas Alexander</td>
                <td>Developer</td>
                <td>75</td>
            </tr>
            <tr>
                <td id="author55">Shad Decker</td>
                <td>Regional Director</td>
                <td>45</td>
            </tr>
            <tr>
                <td id="author56">Michael Bruce</td>
                <td>Javascript Developer</td>
                <td>5</td>
            </tr>
            <tr>
                <td id="author57">Donna Snider</td>
                <td>Customer Support</td>
                <td>98</td>
            </tr>


        </tbody>
        <!--<tfoot>
            <tr>
                <td>Name</td>
                <td>Organization</td>
                <td>Number documents</td>
            </tr>
        </tfoot>-->
    </table>


Si je clique sur la ligne de l'id "author53", alors je voudrais qu'il y ait un message qui s'affiche (avec un "alert"). Comment faire svp ?
Salut.
A la place d'afficher l'id dans le message, je souhaiterais que ca affiche la valeur. Par exemple si on clique sur la ligne qui a l'id "author1", il faudrait que le message affiche "Tiger Nixon".
Comme sur l'exemple ci dessous :
https://jsfiddle.net/urhnhhxz/2/

Le seul pb ici, c'est que quand on clique sur le titre "Author", ca met un message. Je voudrais qu'il y ait des messages que pour les lignes.

Est-ce possible svp ?
Modifié par Lucil (17 Aug 2016 - 11:04)