Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2004
    Bay Area -USA

    Disable all items in a form on submit.

    I was wondering if anyone could show me a cross-browser script that would disable all the fields and radio buttons in a form when people click the submit button.

    <<< Please see Forum Guidelines for signature setup. >>>

  2. #2
    Join Date
    Jul 2003
    Unless there is a very good reason to do this -- don't. Instead, try to prevent duplicate submissions on the server side.

    Anyway -- in broad strokes (I don't have time right now to code it myself) but :

    1. Set the onsubmit attribute of the <form> tag to point to a javascript function.
    2. In this function, get the id (or name) of the form tag (document.getElementById('myform'))
    3. Loop through this object, get each element, set its disabled attribute to true.
    4. Finally, trigger the submit() method of the form (document.getElementById('myform').submit())
    In order to understand recursion, one must first understand recursion.
    If you feel like it, you can read my blog
    Signal > Noise

Posting Permissions

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