SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Dec 2001
    Location
    Market Harborough, UK
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post Disabling a form

    Scenario:

    A form is up in the browser, user does what they need to do and hits "Submit". Being the patient soals that they are, they don't wait for the browser to refresh, but start entering more data / following links!

    What I want to do is to disable all form elements and links when the user cliks "Submit". Anyone have some J-S to do this?

    Cheers,

    Paul
    Paul Simpson, BSc, MCNI, MCNE

  2. #2
    SitePoint Addict BenANFA's Avatar
    Join Date
    Apr 2003
    Location
    Bath, UK
    Posts
    353
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any form element can be disabled with the Javascript

    PHP Code:
    document.<FormName>.<ElementName>.disabled true 
    or using the forms and elements arrays

    PHP Code:
    var floop;
    var 
    eloop;

    for( 
    floop=0floop<document.forms.lengthfloop++)
    {
        for( 
    eloop=0eloop<document.forms[floop].elements.lengtheloop++)
        {
            
    document.forms[floop].elements[eloop].disable=true;
        }

    should disable all elements in all forms on the page.

    For links try something like

    PHP Code:
    var loop;

    for( 
    loop=0loop<document.links.lengthloop++)
    {
        
    document.links[loop].onclick="return false;";


  3. #3
    SitePoint Addict
    Join Date
    Dec 2001
    Location
    Market Harborough, UK
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks!

    I'll give these a try.

    Paul
    Paul Simpson, BSc, MCNI, MCNE


Bookmarks

Posting Permissions

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