Home Jsp JSP Value to JavaScript
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

JSP Value to JavaScript

Advertisement
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.

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:

 

Advertisement

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 3, 2009

Ask Questions?    Discuss: JSP Value to JavaScript  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com