Jump to content

Code to force a cascading element to update


Recommended Posts

Hello all,

Im using the following code to combine the values of several fields to create a parent value for a cascading element.  My problem is the cascading elect won't update unless I actually type in the parent field - how can I force the cascade to update?

<script>
document.getElementsByName("InsertRecordFrame_Desc")[0].onchange = function () {{

var box80 = document.getElementsByName("InsertRecordFrame_Collection")[0];

var box81 = document.getElementsByName("InsertRecordLens_Package")[0];
var box82 = document.getElementsByName("InsertRecordInsuranceLevel")[0];
var box83 = document.getElementsByName("InsertRecordInsuranceDet")[0];


box83.value = box82.value + box80.value + box81.value;


}}
</script>


 

 

Link to comment
Share on other sites

Hi @braxwell

You can try using this example:

https://c0dcd456.caspio.com/dp/ad9b7000f144a76884d34da090ed

Virtual4 is dependent on Virtual3. Type in Apple + Pie separately on Virtual1 and Virtual2

<script>
document.getElementsByClassName("cbFormTextField")[0].addEventListener("change", function(){

var v1 = document.getElementsByName("cbParamVirtual1")[0];
var v2 = document.getElementsByName("cbParamVirtual2")[0];
var v3 = document.getElementsByName("cbParamVirtual3")[0];

v3.value = v1.value + v2.value;

var event = new Event('change');
v3.dispatchEvent(event);

})

</script>

I have used 

var event = new Event('change');
v3.dispatchEvent(event);

to trigger a change to make the cascade update. You may modify it to fit your needs.

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...