Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9115533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:27:20+00:00 2026-06-17T04:27:20+00:00

I have a SUBMIT and SAVE button for a form that are by default

  • 0

I have a SUBMIT and SAVE button for a form that are by default listening for Onclick events.
When the form is SUBMITTED OR SAVED – the page resets the scroll position to the TOP of the page.

Recently the users of the applications have requested that the page stay at the bottom of the page where the buttons are located for only a subset of forms.
(These buttons are used across hundreds of other forms so I cannot change the reset of the scrolling globally.)

So the solution that I am trying to implement involves a couple hidden input fields and a few event listeners.

I have added an onmousedown event for these buttons, like so –

// Submit and Save button listeners
  var globalButtons;
  if (v_doc.getElementsByClassName) {
    globalButtons = v_doc.getElementsByClassName('globalbuttons');
  }
  // Internet Explorer does not support getElementsByClassName - therefore implement our own version of it here
  else {
    globalButtons = [];
    var myclass = new RegExp('\\b'+'globalbuttons'+'\\b');
    var elem = v_doc.body.getElementsByTagName("input");
    for (var i = 0; i < elem.length; i++) {
      var classes = elem[i].className;
      if (myclass.test(classes)) {
        globalButtons.push(elem[i]);
      }
    }
  }
  for (var gb = 0; gb < globalButtons.length; gb++) {
    if (globalButtons[gb].name == 'methodToCall.route' ||
        globalButtons[gb].name == 'methodToCall.save') {
      if(globalButtons[gb].addEventListener) { //all browsers except IE before version 9
         globalButtons[gb].addEventListener("mousedown", function(){flagSpecialScrollOnRefresh()},false);
      }
      else {
        if(globalButtons[gb].attachEvent) { //IE before version 9
           globalButtons[gb].attachEvent("onmousedown",function(){flagSpecialScrollOnRefresh()});
        }
      }
    }
    else { continue; }
  }

This code is located in a function called attachButtonListeners

Next, I defined my handler like so and placed it into another function that gets called each time my page is being loaded –

function checkSpecialScrollCase() {
  var spfrm   = getPortlet();
  var sp_doc  = spfrm.contentDocument ? spfrm.contentDocument: spfrm.contentWindow.document;
  var specialScrollExists = sp_doc.getElementById(docTypeButton).value;

  if (specialScrollExists == "YES") {
    sp_doc.getElementById(docTypeButton).value = 'NO';
  }
  // else - nothing to do in this case
}

docTypeButton = REQS_BUTTONS
And it references the following element at the bottom of my JSP page –

<input type="hidden" id="REQS_BUTTONS" value="NO"/>
<a name="anchorREQS"></a>

Notice the anchor tag. Eventually, I need to add the location.hash call into my handler so that I scroll to this location. That part is irrelevant at this point and here is why.

Problem –
My flagSpecialScrollOnRefresh function is NOT setting the value to YES when it should be.

I believe my onClick event is happening too fast for my onmousedown event from happening.

Evidence –
If I place an alert statement like so –

function flagSpecialScrollOnRefresh() {
  var scfrm   = getPortlet();
  var sc_doc  = scfrm.contentDocument ? scfrm.contentDocument: scfrm.contentWindow.document;
  alert("BLAH!");
  sc_doc.getElementById(docTypeButton).value = "YES";
}

And then I examine the element using Firebug – the value is getting SET!
Once I take out the alert – no go!

How do I ensure that my mousedown event gets executed first? Or is this even the problem here????

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:27:21+00:00Added an answer on June 17, 2026 at 4:27 am

    mousedown is part of a click event.

    Whatever you are doing with click events now should be moved to the submit event on the form. That way you can use mousedown, mouseover, or even click on the buttons to do whatever you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a submit button that is used to save a form. Inside the
I have a web page with a form, a submit button for that form,
I have an ASP.Net Page, aspx with its default form. I have a Submit
I have the following HTML code for Save button: <input type=submit onclick=return confirm('Sure to
I have a submit button that changes when the user hovers his mouse over
i have a submit page in html . when i submit the form data,
I have a submit button when i click on that button i am having
I have a form that has three submit buttons as follows: <input type=submit name=COMMAND
My dilemma is this: I have a PHP page with a form that includes
I have one form that has several elements and two submit buttons, one is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.