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

ajax dynamic combo

sridhar anna
Greenhorn

Joined: May 19, 2005
Posts: 23
Hi All,

In a jsp page, I want to create two dynamic combo drop down menus, like you select a make of a car in one box and you can get all the available models in the other box. I do not want the page to refresh. I looked up dwr at http://getahead.ltd.uk/dwr/examples but I am still not clear on how to get going.

Can anyone give me an example or point me in a direction.

Thanks,
Sridhara
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
http://mywelt.net/?q=node/4020

Eric
sridhar anna
Greenhorn

Joined: May 19, 2005
Posts: 23
Hello Eric,

Thank you for the sample chapter. I have a question - In Listing 4: DoubleComboXML.aspx.vb: Server-side creation of the XML response, how would I do the same in a jsp page?

Thanks again,
Sridhara.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You just dynamically create the XML document as it suggest.

Grab the values from the posted form.
Generate your SQL statement
Loop though the results
Build the document as a big string
and write it to the page when done

Is there something you are confused about? Examples of generating xml with jsp is here

Eric
sridhar anna
Greenhorn

Joined: May 19, 2005
Posts: 23
Hello Eric,

I have some questions regarding the sample chapter.

From Listing 9.2:
var loader1 = new net.ContentLoader(url,FillDropDown,null,"POST",strParams);
Question 1 - Where are you using the variable loader1?
Question 2 - For the url you had mentioned DoubleComboXML.aspx. If I write a servlet, what would the url be? And how can I interact with the webpage?

Thank You so much,
Sridhara.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You need to download the source code to get the js file that has the loader in it. You are looking for net.js

http://www.manning.com/books/crane/source

You can call the servlet. Look at this for another explaination:
https://bpcatalog.dev.java.net/nonav/ajax/ajax.html

Eric
sridhar anna
Greenhorn

Joined: May 19, 2005
Posts: 23
Hello Eric,

Thanks for the article(https://bpcatalog.dev.java.net/nonav/ajax/ajax.html). Its more clear now.

Sridhara.
--
sridhar anna
Greenhorn

Joined: May 19, 2005
Posts: 23
Hi All,

I have two drop down menus where if the user selects from the first drop down menu, i am using ajax, and querying the database and populating the second drop down menu. Now when the user makes a selection from the second drop down menu and clicks on a submit button, I use the values selected from the first and second drop down menus, and reload the page to generate a report on the same page. Here, after the page reloads, the second drop down menu is becoming empty. How can I retain the values in the second drop down menu with the user selection as "selected". Please advise.

Thanks in advance.
Sridhara.
[ February 20, 2006: Message edited by: sridhar anna ]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You need to have the serverside code realize that there was data in the field and have it put it back in. Or a worse way is try to do it with an ajax method.

Eric
sridhar anna
Greenhorn

Joined: May 19, 2005
Posts: 23
Originally posted by Eric Pascarello:
You need to have the serverside code realize that there was data in the field and have it put it back in. Or a worse way is try to do it with an ajax method.


Can you kindly explain the worse way.

Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: ajax dynamic combo