Loading ...
Sorry, an error occurred while loading the content.
 

Re: how to Populate drop down list dynamically in a Container

Expand Messages
  • omairaasim
    Thanks a lot lou - that info seems very useful - I will try this and update - thanks a lot for your time. ... myHandler); ... .options.length]=opt; ...
    Message 1 of 3 , Nov 28, 2007
      Thanks a lot lou - that info seems very useful - I will try this and
      update - thanks a lot for your time.

      --- In ydn-javascript@yahoogroups.com, "lou_tribal" <lou_tribal@...>
      wrote:
      >
      > 1. Add an event listener on your category drop down in order to catch
      > when a selection is made, something like:
      >
      > // If you keep your drop down as a dom object use it instead of
      > getting it like this
      > var mySubCategorySelect =
      > document.getElementById("mySubCategorySelectId");
      > YAHOO.util.Event.addListener(mySubCategorySelect, "change",
      myHandler);
      >
      > 2. In your event handler myHandler make your call to your server and
      > retrieve the data list, something like:
      >
      > var callback =
      > {
      > success: function(response){
      > var mySubCategorySelect =
      > document.getElementById("mySubCategorySelectId");
      >
      > if(response.responseText){
      > var jsonResp = response.responseText;
      > var jsonObj = JSON.parse(jsonResp);
      > var subCats= jsonObj.subCatList;
      > for(i=0; i<subCats.length; i++)
      > {
      > opt = document.createElement("option");
      > opt.value = subCats[i].customerId;
      > opt.text = subCats[i].name;
      > mySubCategorySelect[mySubCategorySelect
      .options.length]=opt;
      > }
      > }
      > },
      > failure: function(response){ // do whatever you want in case of
      > failure}
      > }
      > var tObj = YAHOO.util.Connect.asyncRequest( "GET",
      > "urlToQueryForData", callback );
      >
      > Where urlToQueryForData is the url to call to retrieve your sub
      > category list (you will pass as parameter which category has been
      > selected to retrieve the corresponding sub category).
      > in the example I used JSON as the returned format but you can use
      > whatever you want.
      >
      > <
      >
      > --- In ydn-javascript@yahoogroups.com, "omairaasim" <omairaasim@>
      > wrote:
      > >
      > > Hey Guys,
      > >
      > > I'm thinking of using the container example
      > >
      >
      (http://developer.yahoo.com/yui/examples/container/dialog-quickstart_clean.html)
      > > in my web application to accept user input.
      > >
      > > One of the questions on the form is a "Category" drop down list. Upon
      > > selecting a category, I have to fetch all the subcategories for that
      > > category from the "Database" and populate the second drop down list.
      > >
      > > Is it possible to do this using the Yahoo Container. That is fetch the
      > > data from the database and display in the container even before
      > > hitting the submit button.
      > >
      > > If anyone can throw in a quick example or point me in the right
      > > direction, I would really appreciate it.
      > >
      > > Thanks
      > >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.