View Full Version : Active Element Question

10-21-2003, 01:01 AM

I found that IE supports being able to get the current active Element, is this an IE only feature or is there another way to get the current active element of a form?

Essentially I have a forum with a number of buttons that toggle to different settings depending on the status of things. I am currently using one forum and one verify JavaScript function to submit. The names of each of these buttons have been built up to contain information on the different items on the page. These names can change.

I would like to have the JavaScript be more descriptive in it messages, but I am not sure how to retrieve the name of the button that was pressed. I know I can loop through the elements, but I don't know how to tell which button the user pressed.

Please let me know if submitting code or more details would be helpful at this time or not.


10-21-2003, 01:57 AM
document.onclick = function() {
var e = event;
if(e.srcElement.tagName.toLowerCase() == "input" && e.srcElement.getAttribute("type") == "button")

I'm assuming your code is IE-only....if not, please say so and I'll revise the code.

10-21-2003, 02:03 AM
Hi nolachrymose,

I am not using IE only, my apologies I should have been more specific. The form needs to support as many browsers as possible, but IE and Netscape (for the MAC as well as Windows).

Thanks for the quick response.

10-21-2003, 02:12 AM
One more thing, for the form I am using the onSubmit to confirm if that is the button/action the user wants to take. I am not completely certain how to use onClick function with the onSubmit. Will I now need to call the form.submit() from the onClick function and use a confirm in the onClick function for the validation? Or will the onSubmit still work?

Thanks again,