473,473 Members | 1,482 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

problem in : Displaying an image and autorefresh it for every 30 seconds

10 New Member
[HTML]<HTML>
<HEAD>
<SCRIPT type="text/javascript">
var ld;
function func1()
{
var l=document.form1.loc.value;
var d=document.form1.degree.value;
ld=l+d;
func2();
}
function func2()
{
if (ld==chennaigrad)
{
var graph='<table> <tr><td> <img src="..... some url , which returns an image got from webservices"' >
document.writeln(graph);
document.close();
}
}
window.setInterval("func2();",30000);
</SCRIPT>
</HEAD>

<BODY>
<TABLE>
<FORM name="form1" action="" method="GET" onSubmit="func1();">

<SELECT name="loc">
<OPTION value="hyderabad">Hyd</OPTION>
<OPTION value="banglore">Bang</option>
<OPTION value="chennai">Madras</option>
</SELECT>

<SELECT name="degree">
<OPTION value="grad">B.Tech</OPTION>
<OPTION value="postgrad">M.Tech</option>
</SELECT>

<TD><input type='submit' value='Go'></TD>

</TR>
</FORM>
</TABLE>
</BODY>
</HTML>[/HTML]
Mar 12 '08 #1
8 2544
gits
5,390 Recognized Expert Moderator Expert
you shouldn't use document.write after the page is loaded ... use innerHTML instead

kind regards
Mar 12 '08 #2
alexscript
10 New Member
Thank You, I have included innerHtml now.
The problem is when i execute this in my firefox, The images are not gettinng refreshed(i mean window.setInterval() is not working). And i tried putting
<meta http-equiv="Refresh" content="30;URL=project.html"> but this is returning to the main page ie., It will again ask me to select the dropdownlist(assuming this code is named as project.html).

Is there any way ,where i can refresh only images directly. (Or )
As below, i should be able to call a function every 30seconds, ( but it is not getting the new data in this case.) When i execute this in my internet explorer, i am able to see that the images are being refreshed every 30 seconds, but to my surprise i dont see any changes in the image. I am using webservices link as image, where the url remains remain, but the graph keeps changing, but in this case it is redrawing the old image not getting the new image. When i again click on the submit button, i am able to see the new image.


Help me out..

[HTML]<HTML>
<HEAD>
<SCRIPT type="text/javascript">
var ld;
function func1()
{
var l=document.form1.loc.value;
var d=document.form1.degree.value;
ld=l+d;
func2();
}
function func2()
{
if (ld==chennaigrad)
{
var graph='<table> <tr><td> <img src="..... some url , which returns an image got from webservices"' >


var d=document.getElementId("sometext");
d.innerHTML=graph;

}
}
window.setInterval("func2();",30000);
</SCRIPT>
</HEAD>

<BODY>
<TABLE>
<FORM name="form1" action="" method="GET" onSubmit="func1();">

<SELECT name="loc">
<OPTION value="hyderabad">Hyd</OPTION>
<OPTION value="banglore">Bang</option>
<OPTION value="chennai">Madras</option>
</SELECT>

<SELECT name="degree">
<OPTION value="grad">B.Tech</OPTION>
<OPTION value="postgrad">M.Tech</option>
</SELECT>

<TD><input type='submit' value='Go'></TD>

</TR>
</FORM>
</TABLE>

<div id="sometext">



</BODY>
</HTML>[/HTML]
Mar 13 '08 #3
gits
5,390 Recognized Expert Moderator Expert
first check this:

Expand|Select|Wrap|Line Numbers
  1. if (ld == 'chennaigrad') 
kind regards
Mar 13 '08 #4
alexscript
10 New Member
Sorry, That was my typing mistake here.

I kept those already in my program.

But still its not working..
Mar 14 '08 #5
gits
5,390 Recognized Expert Moderator Expert
you have the following errors:

please fix func2 so that graph is valid html and the method is getElementById():

Expand|Select|Wrap|Line Numbers
  1. function func2() {
  2.     if (ld=='chennaigrad') {
  3.         var graph ='<table><tr><td><img src="..... some url , which returns an image got from webservices"/></td></tr></table>';
  4.  
  5.         var d = document.getElementById("sometext");
  6.         d.innerHTML = graph;
  7.     }
  8.     window.setInterval("func2();",30000);
  9. }
next fix your div to a valid node:

[HTML]<div id="sometext"></div>
[/HTML]
kind regards
Mar 14 '08 #6
alexscript
10 New Member
I did so, and i still has the problem.

Is there any way where i can reload only my images?

Here I am Calling a function for every 30 seconds and iam displaying those images in that function .

The main problem is , I am able to see the image for the first time when i click on the button, but later the function is being called but i dont see that the image is again the same. Its not getting updated?? is this any cache problem or so?? if so , how can i overcome it??


Thanks
--Alex.
Mar 14 '08 #7
gits
5,390 Recognized Expert Moderator Expert
add a unique querystring to the src:

Expand|Select|Wrap|Line Numbers
  1. src = '"your_img_src?d=' + (+ new Date) + '"';
kind regards
Mar 14 '08 #8
alexscript
10 New Member
I changed the code accordingly, but as i am using webservices url, it doesnot end with some .jpg or .gif etc., and when i am using this code for that source, i am unable to see the image at all.

What does this date function do. where can i specify the delay as 30 seconds in this. ?

[HTML]<HTML>
<HEAD>
<SCRIPT language="JavaScript" type="text/javascript">
function func()
{

var source='"http://weeklyrose.com/images/roses.jpg?d="' + (+ new Date ) + '"';
var text='<table border="0" bordercolor="FFCC00" style="background-color:FFFFCC" width="100%" border="4" cellpadding="3" cellspacing="3"><tr><td> <img src='+source+'> </img></td></table>';

var d=document.getElementById("sometext");
d.innerHTML=text;

}

window.setInterval("func1()",30000);

</SCRIPT>
</HEAD>
<BODY>
<div id="sometext">
</div>

</BODY>
</HTML>[/HTML]
Mar 15 '08 #9

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

Similar topics

2
by: Just D | last post by:
Hi, I know how can I cache the ASPX page or any control on this page. But how can I refresh ASPX page automatically every xx seconds? Any script? I need my application to go to the server and...
4
by: vbGansta | last post by:
Hi there. I am using SmartNavigation="True" in one of my pages and it is working except for one instance. If I hit the browser refresh, or a button on my form smart nav works just fine. I also...
1
by: Martin Payne | last post by:
Say I want to write a page that, when delivered, displays a button labelled 'start'. When the button is pressed, a process is initiated server-side that, say, writes random values to a database...
2
by: johnb41 | last post by:
In my app, I need to open up a multipage tiff file, and also display it's thumbnail images IN HIGH QUALITY. (High Quality meaning anti-aliased, and looking good; not rough and pixely) The...
4
by: matty | last post by:
Hello, here is an example of what is driving me totally crazy. This example will show that the first call to "doit()" will print 30 times the image with only one call to the server. Then I have...
7
by: Jake Barnes | last post by:
I've a little webcam program that snaps a picture of me and uploads it every 20 seconds. It automatically uploads the image to my server. It always give the image the same name, and thus it...
4
by: comp.lang.php | last post by:
'll try to explain this as clearly as possible, sorry if it's unclear. You have in your directory /foo 42 images You have in your database metadata for 30 out of those 42 images You have to...
23
by: Peter | last post by:
I have a problem with a page show_image.asp that returns a jpg image under Windows XP Pro SP2. The page sets content type as: Response.ContentType = "image/jpg" While this works perfectly fine...
4
by: shahidrasul | last post by:
i display a pic on picture box and then i want to display another pic after some seconds but problem is that first image is not displaying only display 2nd image 1... display first picture from...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
1
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.