Assuming you are using jQuery, you can do something like this:
HTML:
<select id="countries"> <option>Countries</option> </select> <select id="states" style="display: none"> <option>States</option> </select> <textarea id="address" style="display: none"> </textarea>
JS:
// Cache states list and address box beforehand so we don't have to query every time. var $states = $("#states"), $address = $("#address"); $("#countries").change(function () { // Bind to change event for checking if US selected var isUnitedStates = $(this).val() == "United States"; if (isUnitedStates) { // US is selected, show States $states.attr("id", "address").show() $address.attr("id", "_address").hide() } else { // US is not selected, show Address box $states.attr("id", "_address").hide() $address.attr("id", "address").show() } })
This is not very convenient, but if you really want to make sure, this is the option for you.
source share