File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Return item in array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Return item in array" Watch "Return item in array" New topic
Author

Return item in array

N D Fisher
Greenhorn

Joined: Jun 01, 2007
Posts: 27
Hi,

I have an array of buttons on my web page, and when any one of them is clicked on I need to find out what the array index of that button actually is. So for example, you could have an 'onclick' function in each button so that when you click on it it shows an alert like, 'You clicked on button number 2', etc...

I've tried doing stuff like 'alert(this.id'), but it still doesn't return the index number.

How would I go about doing that?


Thanks.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
JavaScript has no clue what index of the form array a form element is.

You could do a loop through the buttons



you would just have to send this to that function.

Eric
[ June 01, 2007: Message edited by: Eric Pascarello ]
N D Fisher
Greenhorn

Joined: Jun 01, 2007
Posts: 27
OK thanks, I'll give that a try.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Return item in array
 
Similar Threads
Get selected object name or index
using OGNL
Dynamic text fields gives java.lang.IndexOutOfBoundsException
HashMap problem
recursion find number of times int appears in array...