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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Disable mouse entirely!

    I coded a discussion forum which it's buttons (like B,I,U) are the same as in CF posting page...
    I added a function which disables the submit button once the form is being submitted in order to avoid repeated submissions.

    My problem is that after submitting the form, it takes time before the user is being redirected to see his post. In that time, the user can still click the buttons (B,I,U) and if he clicks on it, the submissions get stuck (due to return false.
    I'm looking for a script which will disable any click of the mouse after submission so the user won't be able to click the buttons (B,I,U) after submission.

    I hope I was clear about my prob.
    Thanks for any help!

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Forget that approach - disabling mouse clicks, even briefly, is an accessibility nightmare.

    What you need is flood control - don't allow the same referrer to post more than once every 15 seconds or something; just get your server to reject the others.

  • #3
    Senior Coder
    Join Date
    Jul 2002
    Posts
    1,628
    Thanks
    0
    Thanked 0 Times in 0 Posts
    couldnt you disable the other buttons as you did the submit?

  • #4
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    I'm pretty sure you can disable an entire form.

    I know this works:

    <form disabled>

    I assume you can do something similar with javascript:

    document.myformname.disabled

    I tried testing that, but I don't have any way to delay it to see if the form actually gets disabled.

  • #5
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for your help BUT the buttons has nothing to do with the form. It's just a JS function which adds chars to the text...
    Any other idea?

  • #6
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    I'm still not sure if this idea is the correct solution, but you can just include these buttons in your form or create a new form for them.

    Here's some very rough code...

    <form name="formatting">
    <input type="button" value="bold">
    <input type="button" value="italic">
    <input type="button" value="underline">
    </form>

    <form name="other_form" onsubmit="document.formatting.disabled">
    all your stuff goes here
    <input type="submit">
    </form>

  • #7
    New Coder
    Join Date
    Jun 2002
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how about this

    "In that time, the user can still click the buttons (B,I,U) and if he clicks on it, the submissions get stuck (due to return false)"

    When the user clicks these buttons, functions run certain controls that control formatting and then return false on the associated form submission, right? So you've got something like the following:

    In the header:
    function doItalics () {
    ...
    return false;
    }


    in the body
    <input type=button value=italics onclick=doItalics()>

    (at least I'm guess it's something kinda like it).

    Why don't you redirect the doItalics function to not return false after submission? For instance:

    in the header
    function doItalics () {
    ...
    return false;
    }
    function submitForm () {
    doItalics = dummyItalicsFunction; // syntax might wrong
    document.formname.submit();
    }

    function dummyItalicsFunction () {
    window.status = "You've already submitting your form. Please wait.";
    }

    in the body
    <input type=button value=italics onClick=doItalics()>
    <input type=button value=submit onClick=submitForm()>

    This script essentially calls the submit action of the form manually through a javascript click and submit method, and in the meantime disables the italics, mainly the return false portion. This particular script might be hurting for actual syntax (eg, not sure if it's doItalics = new Function { whatever }) but I know something of this nature can be done, and then thge return false never happens.

    Anyone want to comment on the correction of the above redefinition is welcome to it. I'm aiming at a concept, but didn't test it.
    If at first you don't succeed, spend more time online researching javascript!
    Beck

  • #8
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Beck
    I really like your suggestion.
    Let me check it...


  • #9
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Originally posted by brothercake
    Forget that approach - disabling mouse clicks, even briefly, is an accessibility nightmare.

    What you need is flood control - don't allow the same referrer to post more than once every 15 seconds or something; just get your server to reject the others.
    I don't want to use server-side where I can use JS - why make the server tired?

  • #10
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Is there a way to run a loop and change/disable all the HREFs property for all the <a> tags?

  • #11
    New Coder
    Join Date
    Jun 2002
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ...

    Here's a link disable possibility:

    in the head:
    var myLinks = new Array ();
    myLinks[0] = "http://www.yahoo.com/";
    myLinks[1] = "http://www.google.com/";
    myLinks[2] = "http://javascript.internet.com/";

    in the body, each a tag looks something like:
    <a href="JavaScript: window.location = myLinks[0];">Visit Yahoo!</a>

    of course, you have to assign the array properly, and all that. But if you follow this pattern for every link on the page, then you can disable all the links you want to by calling the following function:

    function disableAnchors () {
    for (var i = 0; i < myLinks.length; i++)
    myLinks[i] = "#";
    }

    I suppose you'd call it after submitting your form:
    function submitForm () {
    ...
    disableAnchors ();
    ...
    }

    That way, none of the links go anywhere.

    Any of the Gurus see any yuckies in my script? Don't let me steer this guy wrong!
    If at first you don't succeed, spend more time online researching javascript!
    Beck

  • #12
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I thought that there was a way of doing it without creating the array manually (like in images...).

    Anyway, I had a better idea and it works: I put an empty <span id="span1"> before the post form, and wrapped the form itself with <span id="span2">
    and onSubmit I:
    1. span2.style.display='none';
    2. span1.innerHTML = 'Please wait while posting';

    It works fine for me, will it be compatible with other browser (than IE 6)?

    Thanks.

  • #13
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts
    anyone know about he compatibility?

  • #14
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It won't work in other browsers unless you change your references:

    span2.style.display='none';

    should be:

    document.getElementById("span2").style.display='none';

    Using the IE only shortcuts to objects is the primary way to make pages that could easily be cross-browser into IE only pages.

  • #15
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Didn't know that, thanks Roy!


    I wish I had more time to learn...
    SCHOOL SUCKS!!!


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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