File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes how to transfer data from javascript to jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to transfer data from javascript to jsp" Watch "how to transfer data from javascript to jsp" New topic
Author

how to transfer data from javascript to jsp

dineshiop kumar
Greenhorn

Joined: Mar 05, 2009
Posts: 13
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>jQuery Example 3</title>

<script type="text/javascript" language="javascript" src="WEB-INF/jquery-1.2.6.js"></script>
<script type="text/javascript" language="javascript" src="WEB-INF/jquery.validate.js"></script>
<script type="text/javascript" language="javascript">
//Our validation script will go here.
$(document).ready(function(){
//validation implementation will go here.
$("#TestForm").validate({
rules: {
txtFirstName: {
required: true
},
txtLastName: {
required: true,
minlength: 2
}
},
messages: {
txtFirstName: {
required: "* Required"
},
txtLastName: {
required: "* Required",
minlength: "* 2 Characters Required."
}
}

});
})
</script>

<style type="text/css">
#container {
width: 350px;
height: 8em;
border: 1px #009933 solid;
background-color:#66FF66;
display:block;
}

label, input{
margin:2px 0px 1px 4px;
}

label {
margin-top:3px;
font-family:"Times New Roman", Times, serif;
font-size:1.1em;
}
</style>
</head>

<body>
<div id="container">
<form id="secondform.jsp" method ="get">
<label for="txtFirstName">First Name: </label><br />
<input name="txtFirstName" type="text" id="txtFirstName" title="Please Enter a First Name" /><br />
<label for="txtLastName">Last Name:</label><br />
<input name="txtLastName" type="text" id="txtLastName" title="Pleaes Enter a Last Name"/><br />
<input type="submit" value="Submit" id="btnSubmit" />
</form>
</div>
</body>
</html>

Surya Kant
Ranch Hand

Joined: Mar 29, 2005
Posts: 104
Where is the JSP?What actually you are trying to say?
Muhammad Ijaz
Ranch Hand

Joined: Mar 03, 2009
Posts: 34
Use hidden fields to place data from javascript to jsp. On the event of Onclick or Onsubmit etc.., call the javascript function that will place the data into the hidden fields of the form.


Regard
Pomy


IBM Certified WebSphere Commerce Application Developer

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

So what is your question? Simply posting a bunch of unformatted code isn't going to get you much help.

Also, please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information. You can go back and change your post to add code tags by clicking the button on your post.

And finally, as this is a JavaScript, not a JSP question, it has been moved to a more appropriate forum.




[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
To the point: you use input fields to send request parameters to the server side. To send hidden input values, use input type="hidden". To set those values using Javascript, just access and alter the HTML DOM the usual way.

Fairly simple all.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to transfer data from javascript to jsp