kytan5 Posted January 2, 2017 Report Share Posted January 2, 2017 Hi I notice whenever I use javascript within caspio datapage and do a preview, it seems to work. However when I save my datapage and have it deployed to my web environment, the script does not work at all. Anyone know why and how I can fix this? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Mathilda Posted January 4, 2017 Report Share Posted January 4, 2017 On 1/2/2017 at 4:15 PM, kytan5 said: Hi I notice whenever I use javascript within caspio datapage and do a preview, it seems to work. However when I save my datapage and have it deployed to my web environment, the script does not work at all. Anyone know why and how I can fix this? Thanks in advance. Hi You may try checking the direct URL of the datapage (URL type of deployment). If it works on direct URL and doesn't work on your site, you need to check your webpage. Hit F12 and check console, do you see errors there? Also what that script should do? I know that redirection doesn't work if you use iframe type of deployment. If the datapage is not authenticated you can send me an URL in private message, I'll check. Quote Link to comment Share on other sites More sharing options...
kytan5 Posted January 4, 2017 Author Report Share Posted January 4, 2017 I checked F12 and it tells me TypeError: totalField is undefined This error comes from a javascript which is in a HTML block which I copied from another thread in this forum. (see script below) So, the live webpage does not recognise var totalField = document.getElementsByClassName('cbFormData')[0];?? <script type="text/javascript"> // Caspio form elements var UnitCostField = document.getElementById('InsertRecordLocalUnitCost'); var qtyField = document.getElementById('InsertRecordUnit'); var totalField = document.getElementsByClassName('cbFormData')[0]; var caspioForm = document.getElementById('caspioform'); // Event handler var calculateTotal = function (event) { // TODO: Do something on value change --> totalField.innerHTML = UnitCostField.value * qtyField.value; } // Run total calculation on input to any of these two fields UnitCostField.addEventListener('input', calculateTotal); qtyField.addEventListener('input', calculateTotal); </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.