Jump to content
CoopperBackpack

How to receive the value from the field to the HTML block

Recommended Posts

Hi @CoopperBackpack

Hope you are well.

Here is the code that would let you to achieve the result. You should insert it in your HTML block.  And I will explain the code below. Please be aware, that I used Virtual Field for this example with name "cbParamVirtual1" as a Calculated Value, since in Caspio  virtual field has syntax [@cbParamVirtual1].  You can put there your own field name if needed instead of "cbParamVirtual1"

<div class="message"></div>

<script type="text/javascript">
document.addEventListener('DataPageReady', function (event) {
  
     document.querySelector('input[id*="cbParamVirtual1"]').addEventListener("change", myFunction); 
   
      function myFunction(event) {
   
          let virField = event.target.value;
          document.querySelector('.message').innerHTML = "your text should be here " + virField;
     
          document.removeEventListener('DataPageReady', myFunction);
     }        
});
</script>

 

This is the part where you insert text, added by JS code::

<div class="message"></div>

 

The JS code has place, where you should enter the text you want to have in HTML block.  Here is this part, replace "your text should be here " for the one you need.

document.querySelector('.message').innerHTML = "your text should be here " + virField;

 

Hope it helps.

 

Regards,

Johnny

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...