Here default the state drop down is loaded
my country dropdown is
<select id="countrydrp" name="countrydrp" class="required" onchange="changeStateType();">
<option value="">Select State</option>
<option value="US">USA</option>
<option value="IN">INDIA</option>
//some more options
</select>
my state drop down is
<select id="statedrp" name="statedrp" style="width: 80px; padding: 5px; height: 30px; width: 215px;" class="" onchange="validteSelected();">
<option value="">Select State</option>
<option value="AK">Alaska</option>
<option value="AL">Alabama</option>
//some more options
</select>
<input type="text" id="statetxt" name="statetxt" class="text" data-error-type="inline" />
if user selects option other than US from Country dropdown
I am trying to hide state drop down and show the textbox as given
my Script is
$(document).ready(function () {
$("#statetxt").hide();//i am hiding the textbox on page loads
});
function changeStateType() {
debugger;
var selVal = $("#countrydrp option:selected").val();
if (selVal == "US") {
$("#statetxt").hide();
$("#statedrp").show();
$("#statedrp").addClass("required");
}
else {
$("#statetxt").show();
$("#statedrp").hide();
$("#statetxt").addClass("required");
}
}
now the problem is both are showing after the i select any country option
If i Select Tunsia(other than US) Then the dropdown and the textbox appears
If i Select United States Then the two dropdowns appears
