Suppose your rows looked like this:

<tr id="row_1"><td>text</td></tr>
<tr id="row_2"><td>text</td></tr>
<tr id="row_3"><td>text</td></tr>

$("tr").click(function () {
    $(".clicked").removeClass("clicked");
    $(this).addClass("clicked");

    var row_id = this.id.split('_')[1];  // e.g. 2
    $("#hiddenField").val(row_id);  // hiddenField is the ID of the
hidden field
});


On Oct 1, 9:48 am, Chuk <violinssoundc...@gmail.com> wrote:
> Hi.  I have a table set up with a .click() function on each row so
> that if it is clicked on, a class is added to the row thus changing
> the background, etc.  I was wondering if there was is a way to take
> the id of the row that was clicked and populate a hidden field with
> it.  What would I need to include in my .click() function for this to
> work?
>
> Here is my current one:
> $("tr").click(function () {
>     $(".clicked").removeClass("clicked");
>     $(this).addClass("clicked");
>
> });
>
>

Reply via email to