Jump to content
kytan5

Javascript works in preview but on live webpage does not work

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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>

 

Share this post


Link to post
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...