Dynamically Changing an Image

J

Jerry Camel

I am interacting with an OCX on the client side. In the Onload event of the page, I am checking a property of the OCX: Is the port open or closed.

If the port is open, I want a certain image to appear. If the port is closed, a different image.
Sounds pretty straight forward.

Since this is dependent upon a property of a client side component, I can't do this with VB .net on the server, right?

So I was trying to use vbscript on the client like this:

If Form1.CardReader.PortOpen = True Then
Document.getElementById("lblPortStatus").innerText = "Card reader is active."
Document.getElementById("imgStatus").setAttribute("src", "images/CR_On.jpg")
Else
Document.getElementById("lblPortStatus").innerText = "Card reader is NOT active."
Document.getElementById("imgStatus").setAttribute("src","images/CR_Off.jpg")
End If

What I've kinda figured out is that I can't really just change the src text 'cause I'm already at the client. So how do I have the images "cached" so that I can change the src dynamically? Or am I completely misunderstanding the problem?

Any help is appreciated. Thanks.

Jerry
 
S

sreejith.ram

following javascript would change an image to diffrent one

document["imgStatus"].src = "images/CR_On.jpg";

the VB Script syntax would be following ?.. I am not very familair with
VB Script

document("imgStatus").src = "images/CR_On.jpg"
 
E

Eliyahu Goldin

Jerry,

Sure you can set the src on the client. The image control will get another image and render it, no problem.

Eliyahu

I am interacting with an OCX on the client side. In the Onload event of the page, I am checking a property of the OCX: Is the port open or closed.

If the port is open, I want a certain image to appear. If the port is closed, a different image.
Sounds pretty straight forward.

Since this is dependent upon a property of a client side component, I can't do this with VB .net on the server, right?

So I was trying to use vbscript on the client like this:

If Form1.CardReader.PortOpen = True Then
Document.getElementById("lblPortStatus").innerText = "Card reader is active."
Document.getElementById("imgStatus").setAttribute("src", "images/CR_On.jpg")
Else
Document.getElementById("lblPortStatus").innerText = "Card reader is NOT active."
Document.getElementById("imgStatus").setAttribute("src","images/CR_Off.jpg")
End If

What I've kinda figured out is that I can't really just change the src text 'cause I'm already at the client. So how do I have the images "cached" so that I can change the src dynamically? Or am I completely misunderstanding the problem?

Any help is appreciated. Thanks.

Jerry
 
J

Juan T. Llibre

I never would have figured you for an HTML
green background color user, Eliyahu.

;-)




Jerry,

Sure you can set the src on the client. The image control will get another image and
render it, no problem.

Eliyahu

I am interacting with an OCX on the client side. In the Onload event of the page, I am
checking a property of the OCX: Is the port open or closed.

If the port is open, I want a certain image to appear. If the port is closed, a
different image.
Sounds pretty straight forward.

Since this is dependent upon a property of a client side component, I can't do this with
VB .net on the server, right?

So I was trying to use vbscript on the client like this:

If Form1.CardReader.PortOpen = True Then
Document.getElementById("lblPortStatus").innerText = "Card reader is active."
Document.getElementById("imgStatus").setAttribute("src", "images/CR_On.jpg")
Else
Document.getElementById("lblPortStatus").innerText = "Card reader is NOT active."
Document.getElementById("imgStatus").setAttribute("src","images/CR_Off.jpg")
End If

What I've kinda figured out is that I can't really just change the src text 'cause I'm
already at the client. So how do I have the images "cached" so that I can change the src
dynamically? Or am I completely misunderstanding the problem?

Any help is appreciated. Thanks.

Jerry
 
E

Eliyahu Goldin

Well, gone are those days when you could tell a real programmers by his
non-stop typing into a black MSDOS screen. Now you have to look into his
html background...:)

Eliyahu
 
J

Jerry Camel

After all, the problem wasn't my code... Just where I had it in the document. Thanks for the input.
Jerry,

Sure you can set the src on the client. The image control will get another image and render it, no problem.

Eliyahu

I am interacting with an OCX on the client side. In the Onload event of the page, I am checking a property of the OCX: Is the port open or closed.

If the port is open, I want a certain image to appear. If the port is closed, a different image.
Sounds pretty straight forward.

Since this is dependent upon a property of a client side component, I can't do this with VB .net on the server, right?

So I was trying to use vbscript on the client like this:

If Form1.CardReader.PortOpen = True Then
Document.getElementById("lblPortStatus").innerText = "Card reader is active."
Document.getElementById("imgStatus").setAttribute("src", "images/CR_On.jpg")
Else
Document.getElementById("lblPortStatus").innerText = "Card reader is NOT active."
Document.getElementById("imgStatus").setAttribute("src","images/CR_Off.jpg")
End If

What I've kinda figured out is that I can't really just change the src text 'cause I'm already at the client. So how do I have the images "cached" so that I can change the src dynamically? Or am I completely misunderstanding the problem?

Any help is appreciated. Thanks.

Jerry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top