Web Analytics Made Easy -
StatCounter Preventing form submission twice on doubleclick in NN6. - CodingForum

Announcement

Collapse
No announcement yet.

Preventing form submission twice on doubleclick in NN6.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Preventing form submission twice on doubleclick in NN6.

    Hi,
    I have a form in which I have this link :- <a href="javascript:submitform(parameters );"> . In the JavaScript
    function submitform, there is the code for submitting the form.This works fine with single click on both IE, NN6.In IE the form is submitted only once even for double click.But if you double click on the link in NN6, the form is submitted twice. This causes problem. The workaround for this was that we set a flag(indicating form submission) in the submitform function, we also set a timer which calls the function resetflag after 3 seconds.So any click within 3 seconds of the first click will be ignored (so that the form is not submitted for the second click).

    function submitform(params)
    {
    if(flag==0)
    {
    flag=1;
    timeout = setTimeout('resetflag()',3000);
    document.form1.action = someURL;
    document.form1.submit();
    }

    }

    function resetflag()
    {
    flag=0;
    }
    .
    .
    .
    .
    .
    .
    .
    //Javascript variables initialization.Executed while page loading.
    var flag=0;
    var timeout=0;

    But the problem now is that, the event fired on the first click submits the form to the server.The second click is ignored since the flag is 0.But the results to be showed for the first click event fired are not shown.The page just stands still as if no event was fired.I dont want to show any alerts or message like 'Double click is not allowed'. I just want a situation where double click has the same effect as single clicki.e. form should be submitted only once(as in single click) and the results should be displayed. Can Anyone Help?
Working...
X