• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to add items in the dropdown list dynamically on radio button selection

 
Soni Agrawal
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a query related to Java Script as i am very new to JavaScript.
My Problem is...
i have created a group of radio button,1.new car 2.old car
onclick event i want to fetch some data from database and display in the dropdown list box corresponding to new car and old car...as i have tested that data is fetched from database correctly but cudn't display in the drop down list box on the click event of radio buttons.
[ May 27, 2008: Message edited by: Soni Agrawal ]
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You either need to postback the page by submitting a form or you have to load the data with Ajax.

Eric
 
Soni Agrawal
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i m not using any submit button for radio buttons,i m getting data from database thru query that is written in a separate java file..so for every radio button selection,i m creating an object of that java class and calling different different functions according to selection..

actually i m new to javaScript,may be there will be any syntex problem that i m facing..please try to solve my problem
 
Soni Agrawal
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And the dropdown listbox will be on the same page itself.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In order to get that query you have to postback the form. It can be done the classic way [requires the page to refresh and uses onclick with document.formName.submit();] or the Ajax way [does not cause the page to refresh] as I stated before.

Eric
 
Soni Agrawal
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
on submit() what function i have to call
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64994
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can find a good starting tutorial on Ajax in this article.

As you can see, it's more than just any function that you need to call.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64994
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to take the time to compose descriptive subjects for your posts; read this for more information.

This entire forum is devoted to solving JavaScript problems so "JavaScript problem" isn't a very effective title.

You can go back and change your post to add a more meaningful subject by clicking the .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic