JSP Value to JavaScript

JSP Value to JavaScript tells you to pass the value from JSP to JavaScript. The JavaScript create a function that accepts the value from the jsp page.

Ads

JSP Value to JavaScript

        

JSP Value to JavaScript tells you to pass the value from JSP to JavaScript. The JavaScript create a function that accepts the value from the jsp page. 

Understand with Example

In this section, we are going to pass the jsp value to javaScript. For this we have create a function addition() which takes the value from the jsp page. When a user click the button, the function addition is invoked and passed the values in order to add two numbers and then shows the result through the alert box.

 

 

Here is the code of passJspValue.jsp

<%@ page language="java" %>
<html>
<head>
<title>
Pass value from JSP to JavaScript 
</title>
<script language="JavaScript" >
function addition(a,b)
{
var c=a+b;
alert("The Addition of two numbers a and b is"+c);
}
</script> 
</head>
Get the addition of two Numbers<br>
<input type="button" onclick='addition(10,15);' value="Add"/>
</html>

Output will be displayed as:

On clicking the button, the alert box will show you the addition of two defined numbers:

Download Source Code:

 

Advertisements

Share on Google+Share on Google+

JSP Value to JavaScript

Posted on: February 3, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

 

Discuss: JSP Value to JavaScript  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads