NeoInJS Posted September 11, 2016 Report Share Posted September 11, 2016 I have a single update form that receives a parameter in a Virtual field. I need to update an existing field (FulfilledQtyDiaper) by adding its current value and the value of the virtual field. I have this script in my Footer but it is not working. <br /> <SCRIPT LANGUAGE="JavaScript"> function UpdateQty() { var d = parseInt(document.getElementById("cbParamVirtual1").value); var newd = d + parseInt(document.getElementById("EditRecordFulfilledQtyDiaper").value); document.getElementById("EditRecordFulfilledQtyDiaper").value = newd; } document.getElementById("caspioform").onsubmit= UpdateQty; </SCRIPT> Quote Link to comment Share on other sites More sharing options...
nightowl Posted September 13, 2016 Report Share Posted September 13, 2016 Hi NeoInJS, I tried the script on my end and it works out-of-the-box. Please check the following to ensure that the script works on your end: The FulfilledQtyDiaper table field must be a Number. On the Single Record Update DataPage, the FulfilledQtyDiaper must be displayed as a Text Field. You can check this setting in the Standard tab of the Configure Fields screen, under General Options > Form Elements. Hope this helps. Quote Link to comment Share on other sites More sharing options...
chthorne Posted March 21 Report Share Posted March 21 Hi @nightowl, does this feature still work in Caspio? I recreated these fields exactly and put the code in the footer but it doesn't do any thing when I submit. Quote Link to comment Share on other sites More sharing options...
CoopperBackpack Posted March 22 Report Share Posted March 22 Hello @chthorne, The 'onsubmit' event doesn`t work now, please use the 'BeforeFormSubmit' event instead: <script> document.addEventListener('BeforeFormSubmit', function (event) { const d = parseInt(document.getElementById("cbParamVirtual1").value); const newd = d + parseInt(document.getElementById("EditRecordFulfilledQtyDiaper").value); document.getElementById("EditRecordFulfilledQtyDiaper").value = newd; }); </script> If you need further assistance please provide more details about your use case. In the initial question in this thread Virtual field receives a parameter. On your screenshot, it passes a value as parameter. In the code, the values are converted to integers. Perhaps, you have numbers that include decimal palaces so the values should be converted with parseFloat() and not with parseInt(). Quote Link to comment Share on other sites More sharing options...
Barry Posted March 22 Report Share Posted March 22 Hello, I made it to work by using BeforeFormSubmit event instead. The above code looks like the following with that modification: <script> function UpdateQty() { var d = parseInt(document.getElementById("cbParamVirtual1").value); var newd = d + parseInt(document.getElementById("EditRecordFulfilledQtyDiaper").value); document.getElementById("EditRecordFulfilledQtyDiaper").value = newd; } document.addEventListener('BeforeFormSubmit', UpdateQty); </script> 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.