Exforsys.com
 
Home Tutorials JavaScript
 

Passing values to JavaScript Function

 

Passing values to JavaScript Function

Page 1 of 2

Passing values to JavaScript Function

In this JavaScript Tutorial you will learn about how to pass values to and also how to return values from a JavaScript function.



Passing Values to function:

Values can be passed to a function as parameters.


The general syntax for passing values to a function in JavaScript is:



function name_of_function(argument1,argument2,…argumentn)
{


…………………………………………
//Block of Code
…………………………………………


}



In the above argument1, argument2,...argumentn represents the values passed to the function.


For Example:


Suppose a programmer wants to create a function with name exforsys, which takes two values x and y.


These two values are passed from the calling program. Then function takes up the shape as follows:


 



function
exforsys(x,y)
{


…………………………………………
//Block of Code
…………………………………………


}




Suppose the values passed to the function from the calling program are 10 and 15.


Then, from the calling program the function is called as follows:



exforsys (10,15)



Next Page: Returning Values from Function


Read Next: JavaScript Two Dimensional Arrays



 

 

Comments


rasla said:

  The data is insufficient to find an answer
January 13, 2009, 4:08 am

vijaya said:

  how to pass dynamic values to java script function
e.g. <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<asp:Button ID="btnsubmit" runat="server" Text="Submit" OnClientClick="disp_alert()"/>
in "disp_alert()" function i want to pass the value entered in textbox having id "txtName".
January 21, 2009, 2:49 am

john anderson said:

  Can you give an example of passing values from one class to the next?
March 22, 2009, 9:47 pm

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2010 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape