Hi I am new to Jquery and Ajax stuff. please Help me in acheving my solution.
Currenlty I am populating check boxes based on my model values and doing an ajax call to get list of countries for each selected value.
Now I am trying instead of displaying Model values if user clicks on All check box I need to pass All as my selected value so that I can fetch all countries.
So below I added a new check box id saying checkBoxAll so how can I do ajax call if all is selected. Can I write if stmt?
<div id="checkboxes">
<% foreach (var manufacturer in Model.Manufacturer)
{%>
<input type="checkbox" id="<%: manufacturer.Id %>" class="checkbox" value="<%: manufacturer.Description %>" /><%: manufacturer.Description %><br />
<%} %>
<input type="checkbox" id="checkBoxAll" class="checkBoxAll" value="All" /> All <br />
<input type="button" value="GetCountries" class="brands" />
<script type="text/javascript">
$(".brands").click(function (event) {
event.preventDefault();
var selected = "";
var manu = "";
var input = "";
$("#checkboxes input:checked").each(function () {
manu = $(this).val();
selected = selected + "," + manu;
$("#SelectedBrands").val(selected);
});
var productInput = "";
var myUrl = "/Countries/GetCountiresForManufacturer/" + selected;
$.ajax({
url: myUrl,
type: 'get',
success: function (data) {
productInput = data;
$(".divNewCountriesList").html(productInput);
}
});
});