Image src updates only once?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • beast37217
    New Member
    • Oct 2007
    • 4

    Image src updates only once?

    I'm running a javascript routine within an asp.net subroutine in a child window. The script works fine and updates the image and the dropdown box in the parent window then closes. But once it's done that if you try to run it again, the script works but doesn't update the image (unless you refresh the page)

    Any help is really appreciated. (I have to disguise the <script> tags as asp.net doesn't like them within a sub)

    Here's the code...

    [CODE=javascript]jScriptString = "<SCR" + "IPT>"
    jScriptString += "opener.documen t.amend.ImgSrc1 .options.length =0;"
    jScriptString += "var optn=opener.doc ument.createEle ment('OPTION'); "
    jScriptString += "optn.text='"+s aveFileAs+"."+s uppLinksType+"' ;"
    jScriptString += "optn.value='"+ saveFileAs+"."+ suppLinksType+" ';"
    jScriptString += "opener.documen t.amend.ImgSrc1 .options.add(op tn);"
    jScriptString += "opener.documen t.amend.image.s rc='"+suppLinks Dest+saveFileAs +"."+suppLinksT ype+"';"
    jScriptString += "setTimeout('se lf.close();',30 00)"
    jScriptString += "</SCR" + "IPT>"
    [/CODE]

    Thanks for any help
    Last edited by acoder; Oct 26 '07, 08:25 AM. Reason: Added code tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Welcome to TSDN!
    Originally posted by beast37217
    But once it's done that if you try to run it again, the script works but doesn't update the image (unless you refresh the page)
    You mean by opening the child window again? Where are the variables suppLinksDest, saveFileAs and suppLinksType set?

    Comment

    • beast37217
      New Member
      • Oct 2007
      • 4

      #3
      Originally posted by acoder
      Welcome to TSDN!
      You mean by opening the child window again? Where are the variables suppLinksDest, saveFileAs and suppLinksType set?


      Sorry I didn't explain properly, Yes..
      The child script updates the parent window image, then closes itself. But if you re-open the child and select another image the script 'works' because it closes the child at the end but the parent image is not updated

      The variables are set within the aspx subroutine. They are used with the System.Drawing. Image.FromStrea m object - This works fine, as it updates a preview image in the child window, just before the javascript kicks in

      Thanks

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Does the select dropdown get updated? Any error messages?

        Can you show the code for the img element in the parent page?

        Comment

        • beast37217
          New Member
          • Oct 2007
          • 4

          #5
          Originally posted by acoder
          Does the select dropdown get updated? Any error messages?

          Can you show the code for the img element in the parent page?

          Yes the select dropdown is being updated properly and there are no error messages. The script completes becasue the child window closes ok at the end

          This is the parent windows imge element...
          <img src="photos/<%=arrProducts( 22,0)%>" name="image" width="200px" border="0" />

          Thanks

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Give the image an id of "image" and try this:
            [CODE=javascript]jScriptString += "opener.documen t.getElementByI d('image').src= '"+suppLinksDes t+saveFileAs+". "+suppLinksType +"';"[/CODE]

            Comment

            • beast37217
              New Member
              • Oct 2007
              • 4

              #7
              Originally posted by acoder
              Give the image an id of "image" and try this:
              [CODE=javascript]jScriptString += "opener.documen t.getElementByI d('image').src= '"+suppLinksDes t+saveFileAs+". "+suppLinksType +"';"[/CODE]

              Thanks SO MUCH - This works Great.
              I'd spent many hours tearing my hair out with this last night!!

              I owe you a pint !

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                Glad to see that you got it working. Post again if you have any more questions.

                Comment

                Working...