How to link a javascript file to the tpl file?

The release related discussions, plans and questions.

How to link a javascript file to the tpl file?

Postby pgodbole » Wed Nov 12, 2008 7:13 pm

Let's say, I create a button in the tpl file. I write a onclick event for this button like this:

<input type='button' onclick="javascript:showMsg();" value={$arrData[Row1][Item1]|escape}></input>

In the testlink_library.js file, I add the function definition for showMsg():

function showMsg(){
alert("hello");
return true;
}

But when, I click on the button, I see no alert. In my tpl file, I have specified the js file to look into using:
<script type="text/javascript" src="../gui/templates/testlink_library.js"></script>

My tpl file is in the results folder under testlink directory.

Please let me know how I can make the js work from my tpl.
Thanks! :)
pgodbole
TestLink user
 
Posts: 5
Joined: Wed Nov 12, 2008 12:12 am

Postby pgodbole » Wed Nov 12, 2008 7:21 pm

Sorry guys, there's a mistake in the previous post.

I meant to write: <script type="text/javascript" src="../javascript/testlink_library.js"></script>

and the tpl file is in gui/templates.
pgodbole
TestLink user
 
Posts: 5
Joined: Wed Nov 12, 2008 12:12 am


Return to TestLink 1.7 (Closed)



Who is online

Users browsing this forum: No registered users and 4 guests

cron