I am using the geodata API that gives me all countries,states,cities in the world in three different select Lists.
These Lists can not be server side. These Lists take some time to load the options.
I wanna set a specific country, state and city from my C# code behind as selected in the select Lists.
I tried using clientScript and scriptManager in order to call a Javascript function that will set the country, state and city as selected, yet both methods didn't call the function. below is my code:
The select Lists code:
<tr>
<td class="auto-style3" style="border-color: #FFFFFF; color: #FFFFFF; background-color: #000080;">
Country:</td>
<td class="auto-style3" style="border-color: #FFFFFF; color: #FFFFFF;">
<select id="countryId" class="countries order-alpha" name="country">
<option value="">Select Country</option>
</select>
<asp:HiddenField ID="countryValue" runat="server" />
</td>
</tr>
<tr>
<td class="auto-style3" style="border-color: #FFFFFF; color: #FFFFFF; background-color: #000080;">
District:</td>
<td class="auto-style3" style="border-color: #FFFFFF; color: #FFFFFF;">
<select id="stateId" class="states order-alpha" name="state">
<option value="">Select State</option>
</select>
<asp:HiddenField ID="stateValue" runat="server" />
</td>
</tr>
<tr>
<td class="auto-style3" style="border-color: #FFFFFF; color: #FFFFFF; background-color: #000080;">
City:
</td>
<td class="auto-style3" style="border-color: #FFFFFF; color: #FFFFFF;">
<select id="cityId" class="cities order-alpha" name="city">
<option value="">Select City</option>
</select>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//geodata.solutions/includes/countrystatecity.js"></script>
<asp:HiddenField ID="cityValue" runat="server" />
</td>
</tr>
The Javascript function:
function fillCities(countryName, districtName, cityName)
{
var country = document.getElementById("countryId")
country.value = countryName;
var district = document.getElementById("stateId")
district.value = districtName;
var city = document.getElementById("cityId")
city.value = cityName;
}
</script>
