473,396 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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...

Expand|Select|Wrap|Line Numbers
  1. jScriptString = "<SCR" + "IPT>"
  2. jScriptString += "opener.document.amend.ImgSrc1.options.length=0;"
  3. jScriptString += "var optn=opener.document.createElement('OPTION');"
  4. jScriptString += "optn.text='"+saveFileAs+"."+suppLinksType+"';"
  5. jScriptString += "optn.value='"+saveFileAs+"."+suppLinksType+"';"
  6. jScriptString += "opener.document.amend.ImgSrc1.options.add(optn);"
  7. jScriptString += "opener.document.amend.image.src='"+suppLinksDest+saveFileAs+"."+suppLinksType+"';"
  8. jScriptString += "setTimeout('self.close();',3000)"
  9. jScriptString += "</SCR" + "IPT>"
  10.  
Thanks for any help
Oct 26 '07 #1
7 1706
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!
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?
Oct 26 '07 #2
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.FromStream object - This works fine, as it updates a preview image in the child window, just before the javascript kicks in

Thanks
Oct 26 '07 #3
acoder
16,027 Expert Mod 8TB
Does the select dropdown get updated? Any error messages?

Can you show the code for the img element in the parent page?
Oct 26 '07 #4
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
Oct 26 '07 #5
acoder
16,027 Expert Mod 8TB
Give the image an id of "image" and try this:
Expand|Select|Wrap|Line Numbers
  1. jScriptString += "opener.document.getElementById('image').src='"+suppLinksDest+saveFileAs+"."+suppLinksType+"';"
Oct 26 '07 #6
Give the image an id of "image" and try this:
Expand|Select|Wrap|Line Numbers
  1. jScriptString += "opener.document.getElementById('image').src='"+suppLinksDest+saveFileAs+"."+suppLinksType+"';"

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

I owe you a pint !
Oct 26 '07 #7
acoder
16,027 Expert Mod 8TB
Glad to see that you got it working. Post again if you have any more questions.
Oct 26 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Balaji Pooruli | last post by:
Hi, I have a critical requirement. I did search in the forums, but still I am not clear. Here is the requirement. Our Project (ACE) has nearly 400 DB2 tables in production and Test...
8
by: kieran | last post by:
Hi, I want to download an image from the web and save it locally. I have spent all day messing about with this and am still no where. We have a firewall so i use the below code. I know it...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
7
by: Neo Geshel | last post by:
Greetings. I have managed to stitch together an awesome method of posting text along with an image to a database, in a way that allows an unlimited number of previews to ensure that text and...
9
by: Mark Denardo | last post by:
This is related to another post I submitted, but I'll be more precise this time. I have a web page that contains an Image webcontrol that loads its image by: Image1.ImageUrl="<username>.jpg",...
7
by: dino d. | last post by:
Hi- I want to create a dynamic image with areas so that when the user clicks different areas, the user jumps to those pages. The problem is, I can't seem to figure out how to do this efficiently....
0
by: raaman rai | last post by:
This is quite irratiting to find out that my system is enabled with automatic updates and it periodically updates my pc with the latest updates. But recently i encountered network problem once the...
8
by: Jomba | last post by:
Hi everyone, In folder image i have 24 pictures, and i would like to have some javascript that will every hour put another picture as background image. I would like to do that on this page...
8
by: Nick | last post by:
Hi there, I have a GridView in an UpdatePanel, each time the UpdatePanels Load event fires I set the DataSource and call DataBind of the grid view. This works great once, I add an item to the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.