function unlockStateForCountry(idCountrySelect, idStateInput, idStateInputHid, countryValue, emptyStateValue) { var index = document.getElementById(idCountrySelect).selectedIndex; var country = document.getElementById(idCountrySelect).options[index].value; var stateInput = document.getElementById(idStateInput); var stateInputHid = document.getElementById(idStateInputHid); if (country == countryValue) { stateInput.disabled = false; stateInputHid.disabled = true; } else { stateInput.disabled = true; stateInput.value = emptyStateValue; stateInputHid.disabled = false; stateInputHid.value = emptyStateValue; } } function unlockStateForCountryNoHid(idCountrySelect, idStateInput, countryValue, emptyStateValue) { var index = document.getElementById(idCountrySelect).selectedIndex; var country = -1; if (index >= 0) { country = document.getElementById(idCountrySelect).options[index].value; } var stateInput = document.getElementById(idStateInput); var stateInputHid = document.getElementById(idStateInput+'__hid'); if (!stateInputHid) { stateInputHid = document.createElement('input'); stateInputHid.id = stateInput.id + '__hid'; stateInputHid.name = stateInput.name; stateInputHid.type = 'hidden'; stateInputHid.disabled = true; stateInput.parentNode.appendChild(stateInputHid); } if (country == countryValue) { stateInput.disabled = false; stateInputHid.disabled = true; } else { stateInput.disabled = true; stateInput.value = emptyStateValue; stateInputHid.disabled = false; stateInputHid.value = emptyStateValue; } }