aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes dropdown & javascript 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 "dropdown & javascript" Watch "dropdown & javascript" New topic
Author

dropdown & javascript

Venkat Babu
Ranch Hand

Joined: Jan 12, 2007
Posts: 47
Hello,

I have a jsp page and in the bottom of the page i have three dropdown list, 3rd one depends on 2nd. And 2nd dropdown depends on 1st one. Once I select 1st drop down, the page is refreshed and 2nd dropdown has new values. But when the page is refreshed, it stays at the begining of the page. So I have to scroll down everytime to select the 2nd dropdown and once i select the 2nd one, it is refreshed and again i have to scroll down for the 3rd one. Once I make the selection, is there a way the page should refresh and stay where the dropdown list are, instead of scrolling down. I using Javascript and in the javascript function i am calling struts action. Thanks a lot.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

Well, you didn't say, but I assume you're looking for a way to avoid the page refresh?

If so, Ajax is the answer for you. With Ajax you can make a request back to the server when the value of a dropdown changes in order to fetch the data (and just the data) needed to populate the dependent dropdown.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Venkat Babu
Ranch Hand

Joined: Jan 12, 2007
Posts: 47
Thanks. I don't know AJAX. Could you please tell me any good sites where I can start learning AJAX and implement this task?

Or is there a way when the page is loaded can I bring the focus on the dropdown? Thanks
[ March 30, 2007: Message edited by: Venkat Babu ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

Here's a tutorial on Ajax: http://developer.apple.com/internet/webcontent/xmlhttpreq.html

You can try just setting focus on the dropdown with a Javascript statement, but not having to refresh a page just for something like this would be a great tool to add to your repetoire.
Venkat Babu
Ranch Hand

Joined: Jan 12, 2007
Posts: 47
Great. Definitely I will look at it. Thanks. I will try to find how to bring the focus on the dropdown using Javascript. Do you or anyone can post a sample java script code of bringing the focus on a particular field in the form when the page is loaded.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65



You do have a Javascript reference handy, don't you?
Venkat Babu
Ranch Hand

Joined: Jan 12, 2007
Posts: 47
Actaully I don't. I very new to Javascript. Today is my third day using Javascript.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

Get yourself a good reference. I'd suggest either (or both) of the O'Reilly Flanagan or Goodman books.
Venkat Babu
Ranch Hand

Joined: Jan 12, 2007
Posts: 47
Great. Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: dropdown & javascript
 
Similar Threads
refresh the contents of combobox
dropdown & javascript
dropdown selection in Struts2
JSP + Listbox
getting values into the drop down list from database