image src changes during a form submittal

Discussion in 'Javascript' started by e, Nov 4, 2003.

  1. e

    e Guest

    IE6. I have a form that can take a while to process once the user submits
    it. So upon submittal of the form, the onclick event for the submit button
    changes some text on the screen to say 'please wait', and also displays a
    little cycling-animated gif (just to encourage the notion that the webpage
    is 'doing something'). The problem is that sometimes only the placeholder
    for the image shows up, and sometimes the image shows up; it's more or less
    a gamble each time whether or not the image will fully load. Here's what
    I'm doing, in a nutshell:

    When the page is initially loaded, I 'preload' the image by creating a new
    image object in js:

    var pleaseWait = new Image(100, 13);
    pleaseWait.src = '/images/pleasewait.gif';

    On the page, there is an img tag that has no src attribute and a
    style.visibility of hidden. It's laying in wait for the submit button to be
    clicked so it can display the image when it's time:

    <img id=animImg width=0 height=0 style="visibility: hidden;" border=0>

    And in the submit onclick handler, this happens:

    animImg.src = pleaseWait.src;
    animImg.style.visibility = 'visible';
    animImg.width = pleaseWait.width;
    animImg.height = pleaseWait.height;

    Sometimes the image shows up, and sometimes it doesn't. I've swapped around
    the order in which animImg's properties are modified, but to no avail. Is
    there a way to do this so that the image reliably loads fully every time the
    submit button is clicked? Any force-the-image-to-display methods, special
    order I should be doing this in, etc?
    e, Nov 4, 2003
    #1
    1. Advertising

  2. e

    Bill M. Guest

    I've had that happen before with simple image loading and no script. I can't
    remember exactly what I did, but after fiddeling with Apache the problem has
    gone away. Maybe that's a clue?

    Sorry I can't offer more.


    Bill
    Bill M., Nov 4, 2003
    #2
    1. Advertising

  3. e

    Fabian Guest

    e hu kiteb:


    > <img id=animImg width=0 height=0 style="visibility: hidden;" border=0>


    > Sometimes the image shows up, and sometimes it doesn't. I've swapped
    > around the order in which animImg's properties are modified, but to
    > no avail. Is there a way to do this so that the image reliably loads
    > fully every time the submit button is clicked? Any
    > force-the-image-to-display methods, special order I should be doing
    > this in, etc?


    istm that having both no SRC attribute and having the visibility
    attribute set to idden is a belt and braces appraoch. Have you tried
    just using one of these? Id try setting the SRC to the normal image, and
    just leaving the visibility to be hidden.


    --
    --
    Fabian
    Visit my website often and for long periods!
    http://www.lajzar.co.uk
    Fabian, Nov 4, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rob Lauer
    Replies:
    2
    Views:
    524
    Chris Jackson
    Jan 26, 2004
  2. Steve Richter

    <txt src= ...> equivalent of <img src= ...>

    Steve Richter, Feb 8, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    2,063
    Laurent Bugnion
    Feb 9, 2006
  3. Greg Johnson
    Replies:
    4
    Views:
    3,051
  4. John Floria

    Form Submittal In Multiple Windows?

    John Floria, Oct 8, 2003, in forum: Javascript
    Replies:
    1
    Views:
    93
    Dom Leonard
    Oct 12, 2003
  5. James Bond 007

    Time stamp on HTML form submittal

    James Bond 007, Nov 9, 2004, in forum: Javascript
    Replies:
    4
    Views:
    146
    James Bond 007
    Nov 14, 2004
Loading...

Share This Page