Welcome Guest, Not a member yet? Register   Sign In
Refreshing a dropdown list when selecting another dropdown list.
#7

[eluser]xwero[/eluser]
did you check if the controller is outputting the cities? In other words what does site.com/index.php/state/src/val gives you?

I'm not an ajax specialist, i'm a jquery user Smile Then your code looks like this
Code:
$('#states').change(function(){ // do when element with the id states changes
  // get the values you need for the url
  var val = $(this).val();
  var src = $(this).attr('id');

  $.ajax({
   url: "index.php/state/"+src+"/"+val, // build url
   success: function(msg){ // do if the ajax request is successful
     $('#cities').html(msg); // add server generated html to the element with the id cities
   }
  });

});
As you see it's a bit more readable than your javascript snippet that handles the XMLHttp object directly.


Messages In This Thread
Refreshing a dropdown list when selecting another dropdown list. - by El Forum - 08-18-2008, 05:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB