www.webdeveloper.com
Results 1 to 3 of 3

Thread: Display a grapic - I know it's simple, but I just can't get it to work

  1. #1
    Join Date
    May 2007
    Posts
    37

    Display a grapic - I know it's simple, but I just can't get it to work

    Right now I've got a terrible sinus condition so my brain probably isn't functioning properly. I'm hoping someone will take pity on me and help me out.

    I've got a simple HTML page used to specify files for uploading. The uploading is done with a PHP routine. It works fine except that larger files take a long time. I just want to display an animated 'wait' gif while the php file processes. I want it to display in the middle of the page (not in a new window) when the Submit button is clicked (after checking to make sure the userid and password have been entered). I know that's simple, but I just can't get it to work. Here's the HTML code. I've put in a comment where (when) I want the graphic to display.

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
      <title>File Upload Page</title>
    <script type="text/javascript">
    function checkrequired(which) {
    var pass=true;
    if (document.images) {
    for (i=0;i<which.length;i++) {
    var tempobj=which.elements[i];
    if((tempobj.name == "user" || tempobj.name == "passwd") && tempobj.value=='') {
    pass=false;
    break;
         }
       }
    }
    if (!pass) {
    shortFieldName=tempobj.name.substring(0,30).toUpperCase();
    alert("Please enter your Username and Password");
    tempobj.focus();
    return false;
    }
    else
    
    // DISPLAY GRAPHIC NOW
    
    return true;
    }
    </script>
    </head>
    
    <body>
    <p>&nbsp;<p>
    <p>
    <font size=+2>
    <center>
    Welcome to the File Uploader.
    <p>&nbsp;<p>
    <table align="center" valign="middle" border=2>
    <tr><td>
    <table border=0>
    <tr>
    <td align="center">
    <form enctype="multipart/form-data" action="uploader.php" method="post" onsubmit="return checkrequired(this);">
    <input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
    <p>Select up to five files to upload.<br>File size must be less than 2.4MB.<br>
    <input name="graphicfile[]" type="file" size=40 value=""><br>
    <input name="graphicfile[]" type="file" size=40 value=""><br>
    <input name="graphicfile[]" type="file" size=40 value=""><br>
    <input name="graphicfile[]" type="file" size=40 value=""><br>
    <input name="graphicfile[]" type="file" size=40 value=""><br>
    
    </td>
    </tr>
    <tr height=20><td align="center" valign="middle"><u>User Authorization</u></td>
    </tr>
    <tr><td>Username: <input type='text' name='user' >  Password: <input type='password' name='passwd'>
    <br><center>Note: Both Username and Password are case sensitive.</td>
    </tr>
    <tr height=40><td align="center" valign="bottom">
    <input value="Upload Files" type="submit"></p></td>
    </form>
    </table>
    </td></tr></table>
    </body>
    Thanks,

  2. #2
    Join Date
    Jun 2004
    Location
    Portsmouth UK
    Posts
    2,678
    Code:
            <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
            <html>
            <head>
              <title>File Upload Page</title>
    <style type="text/css">
    <!--
    
    .mask {
      position:fixed;z-Index:101;visibility:hidden;left:0px;top:0px;width:100%;height:800px;
    }
    
    .mask IMG {
      position:absolute;
    }
    
    -->
    </style>
    
    <script type="text/javascript">
            function checkrequired(which) {
            var pass=true;
            if (document.images) {
            for (i=0;i<which.length;i++) {
            var tempobj=which.elements[i];
            if((tempobj.name == "user" || tempobj.name == "passwd") && tempobj.value=='') {
            pass=false;
            break;
                 }
               }
            }
            if (!pass) {
            shortFieldName=tempobj.name.substring(0,30).toUpperCase();
            alert("Please enter your Username and Password");
            tempobj.focus();
            return false;
            }
            else
    
            // DISPLAY GRAPHIC NOW
             var msk=document.getElementById('mask'),img=msk.getElementsByTagName('IMG')[0];
             img.style.left=(msk.offsetWidth-img.offsetWidth)/2+'px';
             img.style.top=(msk.offsetHeight-img.offsetHeight)/2+'px';
             msk.style.visibility='visible';
    
            return true;
            }
            </script>
            </head>
    
            <body>
            <p>&nbsp;<p>
            <p>
            <font size=+2>
            <center>
            Welcome to the File Uploader.
            <p>&nbsp;<p>
            <table align="center" valign="middle" border=2>
            <tr><td>
            <table border=0>
            <tr>
            <td align="center">
            <form enctype="multipart/form-data" action="uploader.php" method="post" onsubmit="return checkrequired(this);">
            <input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
            <p>Select up to five files to upload.<br>File size must be less than 2.4MB.<br>
            <input name="graphicfile[]" type="file" size=40 value=""><br>
            <input name="graphicfile[]" type="file" size=40 value=""><br>
            <input name="graphicfile[]" type="file" size=40 value=""><br>
            <input name="graphicfile[]" type="file" size=40 value=""><br>
            <input name="graphicfile[]" type="file" size=40 value=""><br>
    
            </td>
            </tr>
            <tr height=20><td align="center" valign="middle"><u>User Authorization</u></td>
            </tr>
            <tr><td>Username: <input type='text' name='user' >  Password: <input type='password' name='passwd'>
            <br><center>Note: Both Username and Password are case sensitive.</td>
            </tr>
            <tr height=40><td align="center" valign="bottom">
            <input value="Upload Files" type="submit"></p></td>
            </form>
            </table>
            </td></tr></table>
            <div id="mask" class="mask" >
             <img src="http://www.vicsjavascripts.org.uk/StdImages/1.gif" alt="loading">
            </div>
            </body>
    Vic

    God loves you and will never love you less.

    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. #3
    Join Date
    May 2007
    Posts
    37
    Vic.

    Many thanks. It works great. One thing, I adjusted the top and left values so my graphic would fall in the middle of the window.

    HTML Code:
      position:fixed;z-Index:101;visibility:hidden;left:500px;top:200px;width:100px;height:100px;
    It does in everything but IE. Does IE require a different style definition?

    Thanks again.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles