Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Oct 2003
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Active Element Question

    Greetings,

    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.

    Thanks!
    ~vgonzalez

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    338
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    document.onclick = function() {
    var e = event;
    if(e.srcElement.tagName.toLowerCase() == "input" && e.srcElement.getAttribute("type") == "button")
    useTheName(e.srcElement.getAttribute("name"));
    }
    I'm assuming your code is IE-only....if not, please say so and I'll revise the code.

  • #3
    New Coder
    Join Date
    Oct 2003
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    ~Vgonzalez

  • #4
    New Coder
    Join Date
    Oct 2003
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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,
    ~vgonzalez


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •