Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Include File help

Status
Not open for further replies.

usp004

ISP
Jul 10, 2000
46
US
I am using an include file in my ASP page which contains JavaScript code to validate a date input field. If I leave the JavaScript code in-line on the ASP page everything works fine... but when I move the JavaScript code to another file and reference it via and INCLUDE file.... it doesnt work... basically it cannot find the function. Here is a simpified code example of what I am doing:

ASP PAGE:

<HTML><HEAD>
<!--#include file=&quot;DateValidation.js&quot;-->
<BODY bgColor=#ffffff>
.
.
.
<INPUT name=Submit onclick=&quot;PrintHello();&quot;>
.
.

----------------------------------------------------------
INCLUDE FILE: (DateValidation.js)

<script language=&quot;JavaScript&quot;>
<!--
Function PrintHello(){
alert(&quot;HELLO&quot;)
}
//-->
</script>


Thanks in advance.
[sig][/sig]
 
Try this example...

default.asp
Code:
<html>
<head>
<!--#include file=&quot;DateValidation.js&quot;-->
</head>
<body>
<input type=button value=&quot;Hello&quot; onclick=&quot;PrintHello();&quot;>
</body>
</html>

DateValidation.js
Code:
<script language=&quot;JavaScript&quot;>
<!--
function PrintHello(){
    alert(&quot;HELLO&quot;);
}
//-->
</script>

A) Unless it was simply misprint then your function was spelled Function (use lowercase)
B) If the .js file is in a different folder if you want to use include file then you must specify the file path relative to the .asp file. As is above both files must be in the same folder. If you use include virtual then you must specify the file path relative to the site.

Hope this helps,
Rob [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top