Hello everyone,

I can't figure out how to insert a javascript function inside a node.

It's a countdown script that uses an external js file and the function needs to be called from within a node.

I set the input filter to php but it didn't work.
All it does is the js file content gets printed as node content

I put the js file in a folder inside sites/all/scripts and here's how i use :


<?php include('sites/all/scripts/countdown.js'); ?>

<script type="text/javascript">
y: 2012; m: 5; d: 25; h: 10; m: 0; s: 0;
</script>

<div id="countdown"></div>

Any ideas ?

thanks

Comments

vm’s picture

Amstram’s picture

Hi,

Thank you, i tried those but that's not exactly what i am looking for.
I need to be able to assign countdowns to different nodes. A little like group buying websites.

Node/1 with a countdown expiring in 3 days, node/45 with a countdown expiring in a week etc.. and some nodes won't have countdown at all.

That's why I need to be able to create countdowns from within nodes.

Thanks

vm’s picture

Just to clarify, they weren't suggested as replacements for what you want. They were provided for you to look at their code for possible clues to aid in your want.

ayesh’s picture

Why don't you just put a src="/sites/all/....." in the script tag? No need to use php include() which should do what you are currently seeing.
If you want to have the js file's content in between script tags, put the php block right after starting the script tag.