Jump to content

Javascript working in preview but not on webpage


Recommended Posts

Hi

I am re-using a javascript code I have used many times successfully in the past, but I can't seem to get it to work now.  It DOES work when I preview the datapage, but on the live website it does not.

I am using a conditional display that I have confirmed still works on other live websites, it was copied directly from a datapage that is currently working but I switched out the field using field picker and the image link...

 

<script>
var link_text="[@field:Make]";
var src_address="https://banjimmie.weebly.com/uploads/2/8/3/6/28360873/chevy_orig.png";
var image_to_display='<a href="' + link_text + '"><img src="' + src_address + '"></a>';
if (link_text=='Chevrolet') { document.write(image_to_display); }
</script>

 

Previewing this directly from the datapage WORKS.  Viewing on my live website DOES NOT.   I use Weebly, and this code still works on all my other weebly sites for other pages.  I am very confused.

I use a hidden page on weebly to view the image rather than uploading to Caspio.  This works on my other sites.

thanks

melissa

live.PNG

preview.PNG

Link to comment
Share on other sites

document.write is not supported anymore this might be the issue.  Try the code below and select the unique field instead of [@field:Id] from picker

 

<div id="link[@field:Id]"></div>
<script>
var isi = document.getElementById("link[@field:Id]");
var link_text="[@field:Make]";
var src_address="https://banjimmie.weebly.com/uploads/2/8/3/6/28360873/chevy_orig.png";
var image_to_display='<a href="' + link_text + '"><img src="' + src_address + '"></a>';
if (link_text=='Chevrolet') { isi.innerHTML = image_to_display; }
</script> 

Is this is not helping either provide the URL to the page here

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