DesiLogi Posted January 24, 2020 Report Share Posted January 24, 2020 Hello, On a Details form, I have a text64000 field (uses Rich Text editor toolbar) to store an address value. This value can come from 3 different places, with different values from each, so, depending on which source the user chooses, I hide/show and use a virtual check box to run javascript on change, to paste a value from another virtual field into the text64000 field. <script> $("[name='cbParamVirtual19']").change(function(){ f_copy_print_address('cbParamVirtual22', 'cke_EditRecordItems_ShipAddress'); var v2 = document.getElementsByName("cbParamVirtual22")[0].value; }); $("[name='cbParamVirtual20']").change(function(){ f_copy_print_address('cbParamVirtual23', 'cke_EditRecordItems_ShipAddress'); var v2 = document.getElementsByName("cbParamVirtual23")[0].value; }); $("[name='cbParamVirtual21']").change(function(){ f_copy_print_address('cbParamVirtual24', 'cke_EditRecordItems_ShipAddress'); var v2 = document.getElementsByName("cbParamVirtual24")[0].value; }); </script> This will take the value from Virtual 22, 23, 24 (they are cascading virtual fields, hence the GetElementsByName) respectively and put it into the Items_ShipAddress field. This works fine in terms of getting the address value to show up in the Items_ShipAddress field. The problem is that when Updated this value is not saved (even though you can see it in the Items_ShipAddress field) UNLESS the user clicks into the Items_ShipAddress field and manually types in at least 1 letter (meaning they have to manually edit the field to save the value, the value the js puts in somehow doesn't 'stick'). I tried saving as a variable the values from Virtual 22, 23, 24 when they're generated (as you can see by that line of code above) and then using that variable to 'save' to the Items_ShipAddress field before Submit (code below). But it's not using the variable if/when the user changes the choice of which virtual checkbox to use (the on Change code). This is the code for before submit: <script type="text/javascript"> document.addEventListener('BeforeFormSubmit', function (event) { document.getElementById("EditRecordItems_ShipAddress").value = v2; }); </script> Any help would be really appreciated (I've tried using calculated values but haven't been able to get it to work for a number of reasons- I'd really just like the js to work). Quote Link to comment Share on other sites More sharing options...
DesiLogi Posted January 30, 2020 Author Report Share Posted January 30, 2020 Ok, I have a fix on this- if anyone needs it in the future. It turns out that there's a hidden element in this circumstance that the value needed to be saved to (maybe because it's a rich text edited field, not sure, but that's what Caspio said). Here's the code for the onChange of the check box that updates the field. I don't think the BeforeSubmit is necessary: $("[name='cbParamVirtual21']").change(function(){ f_copy_print_address('cbParamVirtual24', 'cke_EditRecordItems_ShipAddress'); var v2 = document.getElementsByName("cbParamVirtual24")[0].value; document.getElementById('EditRecordItems_ShipAddress').innerHTML = v2; }); 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.