473,387 Members | 1,528 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How can we call a javascript function present in another jsp file.?

10
<script type="text.javascript" src="/NewPrototype/jsp/caldata.jsp"></script>

I am trying to call javascript function named( show() ) from index.jsp which is present in caldata.jsp but it is not calling that function.

How we can call a function which is present in script of another jsp page?
May 28 '10 #1
8 18107
Dormilich
8,658 Expert Mod 8TB
maybe this works
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" src="/NewPrototype/jsp/caldata.jsp"></script>
otherwise consult the error console.
May 28 '10 #2
aaaash
10
@Dormilich
Thanks for your reply..
I checked in error console it says show() func is not defined.Now what i need to do?
Thanks in advance
May 28 '10 #3
Dormilich
8,658 Expert Mod 8TB
check if you can manually call the JavaScript file in the browser (via address bar).
May 28 '10 #4
aaaash
10
As you suggested i manually called that jsp page where javascript is present it is displaying the content.
To get better idea of what I am doing, I am posting code which is in complete..
in index.jsp

Expand|Select|Wrap|Line Numbers
  1. <A HREF="javascript:void(null);" onclick="showFilterChoices('Language');">
  2. <script type="text/javascript" src="/NewPrototype/jsp/caldata.jsp"></script>
in caldata.jsp
i have defined showFilterChoices function like this

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function showFilterChoices( whichFilter )
  3. {
  4. }
  5.    </script>
What may be the error here?
May 28 '10 #5
Dormilich
8,658 Expert Mod 8TB
external JavaScript files do not use <script> tags (that is for HTML pages to denote a JS section).

your JSP file should send a javascript header.

I suppose your function is not empty in reality.
May 28 '10 #6
aaaash
10
@Dormilich
Yes my function is not empty..

Can u plz tell how can jsp file send a js header..?? Give Ex

In caldata.jsp i am writing some function in <body> of it.So i wrote js function within <script>

Thanks you in advance..
May 28 '10 #7
Dormilich
8,658 Expert Mod 8TB
Can u plz tell how can jsp file send a js header..?? Give Ex
sorry, I’m not a Java guy. I could tell you how to do it in PHP though …

In caldata.jsp i am writing some function in <body> of it.So i wrote js function within <script>
that means, you include an entire HTML page via <script>? no wonder it doesn’t work …

an external JavaScript file must only contain pure JavaScript code. that is, no tags around it.
May 28 '10 #8
aaaash
10
@Dormilich
OK. Thanks for your suggestion.
May 28 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Matthew Louden | last post by:
I want to provide date selection in a page. Basically I want to have similar effect as DTPicker in Visual Basic. My idea is to create a calendar control in mycalendar.aspx. Then I create a...
1
by: hrishikesh | last post by:
hi all can you tell me how to call javascript function in .aspx page i want to call it on onclick of button this codebehind code giving me some other problem like The viewstate is invalid for...
4
by: verci | last post by:
Hi guys, I'm running asp.net 2.0. Does anyone know how to fire or call a javascript function from inside my (VB.aspx) code without assigning it to a control attribute? thank you
4
by: bushi | last post by:
hi every one! i want to call a function of the code file into my javascript code.is it possible?how can i call it?any one knows about it plz rply me as soon as possible,any help will be...
1
by: santosh2003 | last post by:
Hi All, How would we call Javascript function on img click? can we call function which define in codebehind page (.vb page) on img click? Regards Santosh
1
by: DharmendraSingh | last post by:
how i call javascript function in onBlur in datagrid of Struts Layout Please anybody know reply soon Thanks & Regards Dharmendra Singh
17
by: sagar | last post by:
Hi, I have a C file(add.c) in which i have a function called add.now i want to call the same add function from another file sub.c .Can any1 tell how to do that... Thanks in advance Mark
1
KalariaNitya
by: KalariaNitya | last post by:
hello dear, i need ur help i read ur answer in http://www.dotnetspider.com/qa/Question39518.aspx regarding that i want to ask u that, if i used Text1.Attributes.Add("onblur", "return...
1
by: siddu | last post by:
How to call Javascript function in single statement, I have to call these two statements in a single onClick img.Attributes("onclick") = "toggleSidebar(" + IDPREFIXSIDEBARCONTENT + CStr(tab.Id) +...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.