Easy, cheezy.
For your edit link:
<c:forEach var="i" begin="1" end="10">
<a href="javascript:edit(<c:out value="i" />);">edit</a><br>
</c:forEach>
<html-el:hidden property="edit" />
Then your JavaScript function:
function edit(id) {
document.forms[0].edit.value = id;
document.forms[0].submit();
}
That should be enough to get you started. Note that this is from memory, so try before
you buy.
-= J
> -----Original Message-----
> From: andy wix [mailto:[EMAIL PROTECTED]
> Sent: Monday, August 30, 2004 3:04 PM
> To: [EMAIL PROTECTED]
> Subject: Identifying the 'clicked' line when iterating over collection
>
>
> Hi,
> In my jsp page I have an ArrayList of contact objects and I
> use this to
> build an html table; one contact per row. At the end of each
> table row I
> have edit and delete links such that the form looks roughly like:
>
> Name Number
> Fred 1234 edit delete
> Barney 2345 edit delete
>
> What's the best way to identify which link was clicked?
> I know I can make each link name unique by using the index
> used to iterate
> through the collection and assign this to the link ID. Then
> (if I knew how)
> I could get JavaScript to identify which link was selected
> and add this to
> the request/session. Does Struts have a 'posher' way of
> doing this and, if
> not, does anyone have the JavaScript required?
>
> Cheers,
> Andy
>
> _________________________________________________________________
> Want to block unwanted pop-ups? Download the free MSN Toolbar now!
> http://toolbar.msn.co.uk/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]