aspose file tools
The moose likes HTML, CSS and JavaScript and the fly likes returning value from jQuery Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "returning value from jQuery" Watch "returning value from jQuery" New topic
Author

returning value from jQuery

Mukhi Vla
Ranch Hand

Joined: Apr 22, 2010
Posts: 50
Hi all,

Can any one help in how to get value back from jQuery function?

My purpose is to get a selected value from list box when Button is clicked.

When I click on the button I am invoking a function , in that function i am able to alert the selected valu. But I want that value on .jsp page to set the selected value to session.

My code in .jsp page




code from .js file



how to get the selected width back to jsp file?


David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What do you mean by "back to the JSP file"?
Mukhi Vla
Ranch Hand

Joined: Apr 22, 2010
Posts: 50
I want to get the selected value on jsp page from the javascript function. To set that value to session.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56157
    
  13

By the time any JavaScript code runs on the client, the JSP that ran on the server is long gone.

You need to understand how JSP works to see why what you are asking makes no sense. Please read this article.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You'll need to call the server to set anything in session, either via Ajax or a form submission. As Bear says it'll be a good idea to understand the various life cycles involved in web apps before going too much further.
Mukhi Vla
Ranch Hand

Joined: Apr 22, 2010
Posts: 50
I got it. I will have to try AJAX. In my jsp I don't have any form submission. There is a href link that is redirected to a controller class. But before going to the controller I should have this value set.

Thanks
 
I agree. Here's the link: jrebel
 
subject: returning value from jQuery
 
Similar Threads
Problem in using date in WHERE clause in SELECT query in Servlet.
problem with html variable inside jsp
Dblclick and Click event handlers not invoked - used jQuery
how to implement dynamic rows paging when user clicks next or previous links
JQuery.UI Dialog & $().load() & JavaScript