Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update by row count within a table sort

Status
Not open for further replies.

graziaR

Programmer
Joined
Jul 28, 2006
Messages
14
Location
US

Hi,


I have an HTML table and within its body, I create display though a while loop the results of a search.
Then for each row of the displayed results, a javascript submit changes to a java servlet when I click on that particular row.

Now, everything goes well as long as I do not sort by column the table on my web page.
I guess, the index of the row I am trying to change is submitted correctly to the javascript.
But if I do sort the table, the javascript does not get the correct row index, and no changes to the data can be submitted.
Is anyone knowledgeable about the interaction between javascripts and HTML tables of type tablesort ?
How could I make sure that upon sorting the table of results (by whatever column values) I still can get the javascript to work properly on the row I select ?

Many thanks in advance,

Grazia
 
You could store a hidden input in each row with the real index. The input would get sorted with the rows, but still contain the correct data.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
May I ask you to give me an example or to help me find one somewhere online ?

G.
 
I found an easy solution.

One has to make sure that the <form> is defined within the <tr>s
This way:

<tr>
<form ....>
.....
<td>
.....
</td>
<td>
....
</td>
</form>
</tr>

 
That is illegal markup, though, AFAIK. You really would be better off putting your form either inside the TDs or around the table - or using hidden inputs.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top