PDA

View Full Version : Display variables inside a table or DIV



Simora
06-14-2009, 06:38 AM
I have code to determine the correct image for that specific week. The image name changes, ( increments by 1 each Wednesday ) so I determine the current week name by using Javascript.



var newnum = (weekno + 700);
var dex = "/index.htm";
var graphic = ".jpg";
var fold = "/Images/";
var text = "http://www.mysite.com/";
var thisDay=today.getDay();

document.write( text + newnum + fold + newnum + graphic);


This would write http://www.mysite.com/725/Images/725.jpg

How can I get the image URL , ( The section that I can display with document.write ) to load inside a table or DIV. I need to pass the result of this code , so that I can load it when the page open.

Black Label
06-14-2009, 09:21 AM
1- make a new .js file
2- put your week image code :

document.write(" <img src='blablabla'> ");

your case says:


var newnum = (weekno + 700);
var dex = "/index.htm";
var graphic = ".jpg";
var fold = "/Images/";
var text = "http://www.mysite.com/";
var thisDay=today.getDay();
document.write(" <img src='"+text + newnum + fold + newnum + graphic +"'> ");

3- in whatever part of your page, instead of using
<img src=" ">
use
<script src="xx.js"></script>
which xx.js is your week image script.

that's only suggestion, haven't tested it yet

Simora
06-14-2009, 02:02 PM
Hi Thanks:

Looks like it should work. I'll try it out.

Simora
06-14-2009, 06:14 PM
Well, It seemed like a good idea at the time, I just couldn't get it to work. I actually want to display the image, and also will need to display it seperately in an iFrame.

I'll revisit it later.

Thanks

Black Label
06-14-2009, 10:29 PM
well,
http://qu-sa.110mb.com/examples/Simora.htm

check this out.
it's a general example.
i made it simple, depends on the time.
(0 - 11) - (12 - 14) - (15 - 23)
each time interval has a new emotion as example.

Simora
06-15-2009, 04:54 AM
Black Label:

Great! That works. Seems like I was missing some ".

Any idea why IE sometimes refuses to display an iFrame, but 5 minutes later it does? Dont have the same problem with Opera or Firefox.

Thanks for your solution.