BridgeWay Posted January 23, 2017 Report Share Posted January 23, 2017 I want to create a JS if statement that updates a fields value based on another fields value. If the field Virtual2 does not equal "Don't Share" I want the field CON_1 to equal Virtual2 Here is what I used unsuccessfully in the footer of a details page in a tabular report data page... <SCRIPT LANGUAGE="JavaScript"> function con1() { var v2 = parseFloat(document.getElementById("InsertRecordVirtual2").value); if(v2="Don't Share") {} else {document.getElementById("InsertRecordCON_1").value = (v2);} } document.getElementById("caspioform").onsubmit=con1; </SCRIPT> CON_1 is a text data type and Virtual2 is a virtual field drop down that on default = "Don't Share" Thanks Guys! Any help would be greatly appreciated! Quote Link to comment Share on other sites More sharing options...
MayMusic Posted January 27, 2017 Report Share Posted January 27, 2017 This should be what you are looking for: <SCRIPT LANGUAGE="JavaScript"> function con1() { var v2 = document.getElementById("InsertRecordVirtual2").value; if (v2 !="Don't Share") { document.getElementById("InsertRecordCON_1").value = v2; } } document.getElementById("caspioform").onsubmit=con1; </SCRIPT> Quote Link to comment Share on other sites More sharing options...
BridgeWay Posted January 30, 2017 Author Report Share Posted January 30, 2017 Thank you for the reply! Unfortunately the script did not update CON1's value. Does the fact that this script is running in a details page change what should be used in the following line? document.getElementById("caspioform").onsubmit=con1; Should "caspioform" be changed to something like "caspiodetailspage" That is the only thing I can think of as to why CON_1 is not being updated. Thanks again for the help! I really appreciate it! Quote Link to comment Share on other sites More sharing options...
Kurumi Posted July 29, 2019 Report Share Posted July 29, 2019 Hi @BridgeWay, Just an update: You can also use the Calculated Values without using JS. Calculated Value form element generates dynamic calculations that automatically update as users interact with your form. Similar to Formula Fields and Calculated Fields, you can construct the calculation using functions, logic, constants, values from other fields and SQL expressions. For more information about Calculated Values, check this article: https://howto.caspio.com/datapages/datapage-components/calculated-values/ Hope it helps! 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.