Why can’t my JavaScript use the same image more than once at a time?

Good day,
Fine, here is actually what We have.
I’ve received an HTML document in which uses Javascript in order to display plenty of time.However, it doesn’t use wording.It employs images which represent your numbers.
Relating to the amounts 0-9 obtainable in three colorations for users to select from.

Suggestions the problem.It works without getting a flaw As long as the identical image doesn’t ought to be used two times.For model,
In the event the time is definitely 12:47 for example, it units the photos fine- no image is usually repeated.In the event the time is something like 7:37, and also 4:45 though, it’s going to not utilize the same impression twice.So I would be missing among the images for 7 inside first illustration, and among the images to get 4 in the second example.

Why do you find it doing this is there ways to prevent it from transpiring I’m hoping to never have that will load identical image variable more often than once.

I place my signal and expected files right into a.zip record here if that will aid at just about all.

http://cid-7cc3864d98261b77.company.live.com/browse.aspx/Shared%20Files

If you want to replicate the problem that I’m having, just change the time on your hard disk to have a very time along with two on the same numbers in the container.For model, 5:54, and also 3:11

Thanks ahead of time!
-JDDellGuy

An ingredient (or every DOM element for your matter) can only have a one parent in the DOM.

Therefore, at state 9:33, you very first make num30 a child of the actual minute1 period.Then an individual make in which same element a kid of the actual minute2 cover.Once you do that, its no longer a youngster of the particular minute1 course, only that minute cover.

You’re making this a bunch harder in comparison with it ought to be.Put this img tags directly within your HTML program code, then simply just update this src field from the img factor.You don’t really need an assortment here whatsoever.

Just determine the image name influenced by the color and also the value, it is possible to derive this source impression name out of that.

We’d probably prepare a function to perform that:
function setImage(id, colouring, value)

var src = color+value+’.bmp’;
document.getElementById(id).src = src;

id is a id for your img element you need to change.
color is probably the characters r g or even b.
value is the numeric benefit.

You”ll must treat blank to be a special scenario, but this can handle the many number/color a combination.

Your code can be quite complicated with regard to something consequently simple.I removed almost all of the JavaScript and created a super easy alternate variation.You could get the 100 % and dependable modification out of here:

http://pastebin.com/uV6j1ffc

Needless to say, just like your signal, my JavaScript isn’t going to update plenty of time as the item passes – it only displays the present time once the page masses.

Leave a Reply