i want to create dynamic table and drop down menu from lists.
i have 2 questions:
1. for the drop down menu i can run over the list and write the tag <option> inside the loop? it will create the menu with the number of items in the list? there is another way?
2. i am planning to build the table the same way with a loop.
but i want to know how can i get a selected row from the table.
if i have a link in every row how can i know which row was selected?

1. for the drop down menu i can run over the list and write the tag <option> inside the loop? it will create the menu with the number of items in the list? there is another way?

Yes there can be other ways, but in this case it is most simplest and efficient way

2. i am planning to build the table the same way with a loop.
but i want to know how can i get a selected row from the table.
if i have a link in every row how can i know which row was selected?

Not sure what you are attempting to do, but you can provide each row tag "tr" with unique id and use jQuery to handle clicks and return selections. Or there is always option of using buttons/checkboxes/radioboxes for each row. As I said, not knowing your requirements makes it difficult to advice

Yes there can be other ways, but in this case it is most simplest and efficient way

Not sure what you are attempting to do, but you can provide each row tag "tr" with unique id and use jQuery to handle clicks and return selections. Or there is always option of using buttons/checkboxes/radioboxes for each row. As I said, not knowing your requirements makes it difficult to advice

thank you for the answers. i will try to explain my self better.
i want to create a table and in each row there will be a link.
when a user clicks on a link it will go to a servlet and i want to send the selected row to the servlet. how can i do that?

Correct me if I'm wrong, but aren't data in the table first populated by servlet?
If it so then you have some unique IDs you can reuse for creating links with call for servlet plus additional parameter which in this case would be some unique ID, for example book shop would use ISBN as this unique and hyperlink would be as "www.bookshop.com/ServletCall.jsp&itemId=1234"

Correct me if I'm wrong, but aren't data in the table first populated by servlet?
If it so then you have some unique IDs you can reuse for creating links with call for servlet plus additional parameter which in this case would be some unique ID, for example book shop would use ISBN as this unique and hyperlink would be as "www.bookshop.com/ServletCall.jsp&itemId=1234"

I am sorry for replying to this, but shouldn't it be like this:
"www.bookshop.com/ServletCall.jsp?itemId=1234"
instead of a '&'

commented: Well spotted. Thank you! +12

thank you very much.

I am sorry for replying to this, but shouldn't it be like this:
"www.bookshop.com/ServletCall.jsp?itemId=1234"
instead of a '&'

Ooops, $hit does happens specially if you use Mac with Ubuntu. Keyboard layout messed up, sorry for that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.