Jump to content

Copy Value from Calculated Field to Text Area Field


Recommended Posts

When my submission form loads, I have a calculated value field that queries the datasource table and gets the most recently submitted value. I need to find a way to copy this value into my Text Area field.

The Text Area field has the Advanced Text Editor enabled. 

Here is one of my attempts to get this to work. I get no errors, but the value does not show up in the Text Area editor. cbParamVirtual1 is the calculated value and cke_InsertRecordBulletin is what I think is the Text Area element I need to add the value to (I say think because with the editor enabled, there are a ton of elements related to this text area field). Any help is appreciated!

document.addEventListener('DataPageReady', function (event) {
    document.querySelector('[id^="cbParamVirtual1"]').addEventListener("change", myFunction); 
   
      function myFunction(event) {
   
          let calcField = event.target.value;
          document.getElementById("cke_InsertRecordBulletin").value= calcField.toLocaleString();
     
          document.removeEventListener('DataPageReady', myFunction);
     }        
});

 

Link to comment
Share on other sites

Hi @kpcollier,

I found this post that is similar to your question. I just replaced EditRecord with InsertRecord, and used the correct field names. 

Here's the updated script.

<script>
document.addEventListener('DataPageReady', function (event) {
    document.querySelector('[name="cbParamVirtual1"]').addEventListener("change", myFunction); 
   
      function myFunction(event) {
   
          let calcField = event.target.value;
          document.querySelector('#InsertRecordBulletin').value= calcField.toLocaleString();
     
          document.removeEventListener('DataPageReady', myFunction);
     }        
});
</script>

 

:) 

Link to comment
Share on other sites

Hi @kpcollier

The code must be modified. Try the following version:

 

<script>
document.addEventListener('DataPageReady', function (event) {
    document.querySelector('[name="cbParamVirtual1"]').addEventListener("change", myFunction); 
   
      function myFunction(event) {
   
          let calcField = event.target.value;
          document.querySelector('#InsertRecordBulletin').value= calcField.toLocaleString();
          document.querySelector('#InsertRecordBulletin').nextElementSibling.querySelector('iframe').contentDocument.querySelector('body').innerHTML = calcField 
          document.removeEventListener('DataPageReady', myFunction);
     }        
});
</script>

 

Link to comment
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...