Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
I have a .js file
when i call function ehsan11() in another page get this Error : Uncaught TypeError: undefined is not a function(index):1 onclick

Im use in in Button onclick :
JavaScript
<button style="width:250px;" id="sendaccept" class="sendaccept" onclick="ehsan11();">send accept</button>


**when I create a function in this .js file I can call ! But I cant Call this
Now my Fubktion in .js File

U can see my class heare : Click
Posted
Updated 23-Dec-14 19:58pm
v2
Comments
Praveen Kumar Upadhyay 24-Dec-14 1:53am    
Where is your method ehsan13() defined??
‫محم د‬‎ 24-Dec-14 1:58am    
Excuse me ehsan11 I change it. now its true
Sibasisjena 24-Dec-14 2:15am    
Have you included that js file in your page.
‫محم د‬‎ 24-Dec-14 2:25am    
yes !
Sibasisjena 24-Dec-14 3:01am    
Do you have firefox browser? If yes, then open this page in firefox. Also open the firebug console and see there what is the issue.

1 solution

To call any JavaScript function from your markup, that function must be presented in your page in one of these ways:
1. Be part of the page inside a script block
2. To be linked to your page using script block with src attribute
If you do not do one of these you will get an 'undefined' error as the page can not find your function...
https://developer.mozilla.org/en/docs/Web/HTML/Element/script[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900