This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Change Background Image On Object Value
#1
Hello All,

Is there a way to change the background image of an image element via object value? 
Or can I have 4 sets of elements including images, buttons, value dispaly on the same page and change the visibility of them based on a virtual object 250byte value?

Value 1 = Make visible set 1 and hide all the other sets
Value 2 = Make visible set 2 and hide all the other sets
Value 3 = Make visible set 3 and hide all the other sets
Value 4 = Make visible set 4 and hide all the other sets


Thank you in advance
Reply
#2
have you seen this? https://forum.logicmachine.net/showthrea...05#pid2205
------------------------------
Ctrl+F5
Reply
#3
Hello Daniel.

I have done this and works but if I refresh the page the background image is lost. Is there a solution to this?

Code:
$(function(){
  if (typeof grp != 'undefined') {
    grp.listen('32/1/4', function(object, state) {
      var image = $('.hvac_image')[0]
      if (state == 'value') {
        if (object.value == 1) {image.innerHTML = '<img src="scada/resources/img/HVACFlowDiagram1.PNG?1569506491">';}
        else if (object.value == 2) {image.innerHTML = '<img src="scada/resources/img/HVACFlowDiagram2.PNG?1569506498">';}
        else if (object.value == 3) {image.innerHTML = '<img src="scada/resources/img/HVACFlowDiagram3.PNG?1569506503">';}
        else if (object.value == 4) {image.innerHTML = '<img src="scada/resources/img/HVACFlowDiagram4.PNG?1569506509">';}
        }
    });
  }
});


Thanks for your help.
Reply
#4
Hi,

Currently your script is executed on state "value", this means that during init the script is not executed as state is "init" in that case, you could remove the "if (state == 'value') { ... }" condition to have it also executed on init so it is directly triggered after a refresh. Or you can add a extra condition like "if (state == 'init') { ... }"

BR,

Erwin
Reply


Forum Jump: