Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

how to transfer data from javascript to jsp

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where is the JSP?What actually you are trying to say?
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.



 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I don't get it. A whale wearing overalls? How does that even work? It's like a tiny ad wearing overalls.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic