开发者

How to know which row a user selects from an HTML table - GAE Python

Sorry if this is a newbie question. I have searched but found nothing...

Using Python on GAE, I will display a table of, say, customers on an HTML table. The table will show their name and phone number.

I want the user to double-click on a row and have the python Post() method know either the row number double-clicked or the customer number of that row. A 'Select' button on each row would be an acceptable alternative to the double-click.

(I am开发者_开发技巧 trying to replicate or simulate the Windows / Delphi double-click event on a TStringgrid).

My question: is this possible? If so, how or where should I look?

many thanks David


I have never used Python or Delphi (assuming by "I come from Delphi" you mean you are using the Delphi programming language) so forgive me if my answer is not relevant.

One method you could use is to give each tr a custom attribute. For example <tr custID='...'>...</tr>. You could then use jQuery to extract the custID from the tr on double click.

For example:

$("tr").dblclick(function() {
    $(selector).load("http://myurl/pageName.extension?custID='"+$(this).attr("custID")+"'");
});

I think this should do what you want. I have never used the POST method in jQuery, but this would work for GET. You can always look up the POST method on the jQuery website.

Edit:

For compliance with HTML 5 (although it will be non-compliant with HTML 4) you are recommended to use data- attributes, for example data-custID.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜