On Fri, Oct 9, 2009 at 12:00 PM, Chuk <violinssoundc...@gmail.com> wrote: > > I have changed things a little now. Here is an example of my current > code: > > $('#edit').click(function() { > var clickedID = $('.clicked').id; > transNo = ?; //This is where I need to retrieve the row's id > window.location = "GL0002T?action=R&transBatchNo=<!--%batch%-- >>&transNo="+transNo; > }); > > <tr id="1" class="row"> > <td id="Sequence1" style="width: 80px;">1</td> > <td id="Account1" style="width: 85px;">400-04</td> > <td id="Reference1" style="width: 100px;">Ref2</td> > <td id="Journal1" style="width: 114px;">01</td> > <td id="Description1" style="width: 250px; text-align: left;">Desc2</ > td> > <td id="Debit1" style="width: 124px; text-align: right;">100.00</td> > <td id="Credit1" style="width: 124px; text-align: right;border- > right: none;">.00</td> > </tr> > > <tr id="2" class="alt row"> > <td id="Sequence2" style="width: 80px;">2</td> > <td id="Account2" style="width: 85px;">400-04</td> > <td id="Reference2" style="width: 100px;">Ref2</td> > <td id="Journal2" style="width: 114px;">01</td> > <td id="Description2" style="width: 250px; text-align: > left;">Desc2b</td> > <td id="Debit2" style="width: 124px; text-align: right;">.00</td> > <td id="Credit2" style="width: 124px; text-align: right;border- > right: none;">100.00</td> > </tr> > > <input type="button" id="edit" value="Edit Selected"> > > When a row is clicked, I add a class of "clicked" to the row. After > the row is clicked, I click on the Edit button and the .click() > function is executed. I need to be able to retrieve the id of the > clicked row and pass it as a parameter to another program. I hope > this clarifies things. > > Thanks
You're still using an ID that begins with (consists entirely of, in this case) a digit. Change it to something like: <tr id="TransNo1" class="row"> <td id="Sequence1" style="width: 80px;">1</td> <td id="Account1" style="width: 85px;">400-04</td> <td id="Reference1" style="width: 100px;">Ref2</td> <td id="Journal1" style="width: 114px;">01</td> <td id="Description1" style="width: 250px; text-align: left;">Desc2</ td> <td id="Debit1" style="width: 124px; text-align: right;">100.00</td> <td id="Credit1" style="width: 124px; text-align: right;border- right: none;">.00</td> </tr> Of course, if you then want to get the digit from the ID of the TR with class "clicked" for use elsewhere, you'll need to parse it out of the string. You didn't answer my question about the actual values you want to send to the sever. For account, reference, and journal, do you want "Account1", "Reference1", and "Journal1"? Or, do you really want to send "400-04", "Ref2", and "01"? In any case, it'd be more secure to just send just the database primary key and have your server-side logic fetch the data you want to edit. And, in that case, you could append the primary key to your TR iD (eg. "TransNo_YOUR_PRIMARY_KEY_HERE"). But it's difficult to say without knowing more about the server-side logic. Also, you could probably get rid of the class "row", as all TRs are rows by definition. You could change the CSS rule for class "row" to match tr (of this particular table, perhaps) and keep the tr.alt rule.