SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2009
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to make DIV visible on form submit

    Hi,

    I am hoping someone on this forum would be able to assist me. I am trying to make a DIV visible after a user clicks a form submit button that posts to the same page.

    Thanks very much!

    Here is the code that I have came up with so far and it does not work.

    <script>

    void processForm()
    {
    document.getElementById("loadingImg").style.visibility = "visible";

    // document.getElementById("form1").submit();

    }

    </script>

    Here is the line of code with the hidden DIV.

    <DIV style="visibility:hidden;" />
    Form Submitted!
    </DIV>


    Than here is the sample form.

    <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1" >

    <cfinput type="submit" value="Upload" onClick="processForm();" / >

    </form>

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    When the form is posted back to the same page, the old version of the page is destroyed and a new version of the page is then created and shown to the user.

    One possible option is to place a querystring value in the action part of the form, so that the new page can check for that querystring value, and if it's there, the page can then show the submitted message.

    Code html4strict:
    <form action="?submitted">

    Script at end of body, just before the </body> tag.

    Code javascript:
    if (location.search === '?submitted') {
        document.getElementById("loadingImg").style.visibility = "visible";
    }
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2009
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for replying to my question. I managed to resolve my issue and you helped to point me in the correct direction.


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
  •