Benades Posted July 8, 2021 Report Share Posted July 8, 2021 Hi there, Previously @TellMeWhy helped to display values in a span tag which worked great: <div class="col mr-2"> <div class="text-uppercase text-success font-weight-bold text-xs mb-1"><span>Second Level</span></div> <div class="text-dark font-weight-bold h5 mb-0"><span id="secondlvl"></span></div> </div> <script> window.addEventListener('load', function() { document.querySelector("input[name='cbParamVirtual1']").addEventListener('change', function() { document.getElementById('secondlvl').innerHTML = document.querySelector("span[id^='cbParamVirtual7@Data']").innerHTML; }); }, false); </script> Now I need to do the same to fetch a Virtual field value but then add it to an img tag: <img alt="Virtual17" src="https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=[@cbParamVirtual17]"/> Quote Link to comment Share on other sites More sharing options...
TellMeWhy Posted July 8, 2021 Report Share Posted July 8, 2021 6 hours ago, Benades said: Hi there, Previously @TellMeWhy helped to display values in a span tag which worked great: <div class="col mr-2"> <div class="text-uppercase text-success font-weight-bold text-xs mb-1"><span>Second Level</span></div> <div class="text-dark font-weight-bold h5 mb-0"><span id="secondlvl"></span></div> </div> <script> window.addEventListener('load', function() { document.querySelector("input[name='cbParamVirtual1']").addEventListener('change', function() { document.getElementById('secondlvl').innerHTML = document.querySelector("span[id^='cbParamVirtual7@Data']").innerHTML; }); }, false); </script> Now I need to do the same to fetch a Virtual field value but then add it to an img tag: <img alt="Virtual17" src="https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=[@cbParamVirtual17]"/> Put an ID to the img tag, and remove the parameter value at the end <img id="imgelem" alt="Virtual17" src="https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl="/> Update the code you have already, just put a name in the function Add this code to the code you have already document.getElementById('imgelem').src +=document.querySelector("input[name='cbParamVirtual1']").value; this.removeEventListener("change", changer); see above for the whole code what this does is append the value of Virtual1 to the src of the image. the removeEventListener is to make sure this runs only ONCE because for some reason, the code runs twice in Chrome Quote Link to comment Share on other sites More sharing options...
Benades Posted July 8, 2021 Author Report Share Posted July 8, 2021 Thanks @TellMeWhy, Working nicely most of the time. Sometimes it doesn't fetch it but navigating away and back fixes the issue Quote Link to comment Share on other sites More sharing options...
TellMeWhy Posted July 8, 2021 Report Share Posted July 8, 2021 1 hour ago, Benades said: Thanks @TellMeWhy, Working nicely most of the time. Sometimes it doesn't fetch it but navigating away and back fixes the issue Hmm, have you tried other browsers? You can also check F12 > Console if there are any errors when it encounters issues, it only changes values, so it should not come across issues that often Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.