T.J. & Alex, thanks for your suggestion!
On Jul 20, 5:21 pm, "Alex McAuley" <webmas...@thecarmarketplace.com> wrote: > Some people just create an array at page load and push history to the array > (similar to TJ's explination) ... it seems the cleanest way to do it .. you > could also update a hidden element with the id of the element if you wanted > ... using an array allows you to access all hostory on that page of clicked > input elements though! ... I believe its how google do it in thier analytics > package to work out page clicks! > > ----- Original Message ----- > From: "T.J. Crowder" <t...@crowdersoftware.com> > To: "Prototype & script.aculo.us" <prototype-scriptaculous@googlegroups.com> > Sent: Monday, July 20, 2009 11:17 AM > Subject: [Proto-Scripty] Re: Finding the previous element which was clicked > > Hi, > > I'll be interested to see the answers to this question, I'm sure > there's a better way than the way I've done it previously. > > I needed to do something along those lines, keep track of which text > box the user was in before they clicked a button. I ended up keeping > track of the most recent text box in the form to get focus. I wasn't > using Prototype, but in Prototype it would look something like this: > > // At some appropriate scope > var lastFocussed; > > // In an init function, such as when DOM ready, or when you've > rendered the form > $('myform'). > select('input[type=text], input[type=password], textarea, > select'). > invoke('observe', 'focus', function() { > lastFocussed = this; > }); > > That will track which text, password, textarea, or select box last had > focus. Note that it doesn't track radio buttons or checkboxes; you > may want to do that, just add to the list of things being tracked in > the selector. > > HTH, > -- > T.J. Crowder > tj / crowder software / com > Independent Software Engineer, consulting services available > > On Jul 20, 10:42 am, Tharapon Menkham <thara...@gmail.com> wrote: > > Sorry, the last selected element. > > I clicked textbox in form and click the link or button, so I want to > > know the textbox I've selected. > > > Thank you, > > Tharapon > > > On Jul 20, 4:39 pm, "T.J. Crowder" <t...@crowdersoftware.com> wrote: > > > > Hi, > > > > What do you mean by previous? Previous in the DOM, previous in > > > time, ...? The more thorough you are in the info you provide, the > > > more people will be able to help. > > > -- > > > T.J. Crowder > > > tj / crowder software / com > > > Independent Software Engineer, consulting services available > > > > On Jul 20, 10:30 am, Tharapon Menkham <thara...@gmail.com> wrote: > > > > > Does any know how to find the previous element which was clicked? > > > > > Thank you so much, > > > > Tharapon --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---