CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: C#

No Title

279 Views
Copy Code Show/Hide Line Numbers
 
function setWards(o) {
    $.getJSON('/Home/GetWards/?cbd_id=' + o.value, null, function(data) {
        $('#ward').empty();
        $.each(data, function(i, item) {                   
            $('<option/>').attr('value', item.ID).html(item.Name).appendTo('#ward');
        });
    });
}
 
public JsonResult GetWards(int cbd_id)
{
    return (this.Json((from w in db.Wards
                       where w.CBUID == cbd_id
                       select new
                       {
                           ID = w.ID,
                           Name = w.Name
                       }
                       ).ToList()));          
                         
}
 
<%= Html.DropDownList("ward", Model.Wards, new { @class = "sectionDD" })  %>
by Paul
  September 29, 2009 @ 3:55pm
Tags:
Description:
update a select from a ajax jsonresult

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate