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 js file in jsp

Status
Not open for further replies.

yytan

Programmer
May 8, 2002
113
MY
hi there;

in my jsp file, i did this

<script language=&quot;javascript&quot; src=&quot;include.js&quot;></script>

but can i have a short example how to call the method in include.js from the jsp file?
 
In a javascript block ...

<script language=&quot;javascript&quot;>
myFunction();
</script>


or within some HTML ...

<input type=&quot;submit&quot; onClick=&quot;myFunction&quot;>
 
hi;

i know how to use javascript in jsp.

but what if i put the whole javascript into a fil let say include.js

so how to use it from jsp? how to call the include.js function inside the jsp.
 
Yes. I know what you mean !!!!!

As I said before,

In a javascript block ...

<script language=&quot;javascript&quot;>
myFunction();
</script>


or within some HTML ...

<input type=&quot;submit&quot; onClick=&quot;myFunction&quot;>
 
hi there;
i am having error here. it said object expected? pls point out where is my error, thanks.

---fisrt.jsp---

<%@ page language=&quot;java&quot; %>
<%@ page import=&quot;java.util.*&quot; %>
<!DOCTYPE HTML PUBLIC &quot;-//w3c//dtd html 4.0 transitional//en&quot;>
<html>
<head>
<title>Lomboz JSP</title>

<SCRIPT LANGUAGE=&quot;JavaScript src=&quot;first.js&quot;>

chk();

</SCRIPT>

</head>

<body bgcolor=&quot;#FFFFFF&quot;>

<br><center>Time now: <%= new Date() %></center>
<%
out.println(&quot;hello...&quot;);
%>

<form name=&quot;firstForm&quot;>

<input tpye=&quot;text&quot; name=&quot;name&quot;>

<input type=&quot;button&quot; value=&quot; OK &quot; onClick=&quot;chk()&quot;>

</form>

</body>
</html>

----first.js----

function chk() {

var txt = document.firstForm.name.value;


if (txt.length < 1) {
alert(&quot;please key in your name&quot;);
document.firstForm.name.focus();
}
else
alert (&quot;hi ... &quot; + txt);

}
 
You have missed a quote mark ::

<SCRIPT LANGUAGE=&quot;JavaScript src=&quot;first.js&quot;>

should be ::

<SCRIPT LANGUAGE=&quot;JavaScript&quot; src=&quot;first.js&quot;>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top