Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to transfer data from javascript to jsp

 
dineshiop kumar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<!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
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is the JSP?What actually you are trying to say?
 
Muhammad Ijaz
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.



 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic