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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
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: 51
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: 51
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: 61437
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by 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: 51
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: returning value from jQuery