I have a form element (country) I need to create an onchange javascript script such that if country = "USA" then the form element "state" is visible, if country = anything else then state is to be invisible and "county" is to be visible This should be very easy but I am pants at javascript
Well, if you are displaying countries as a drop-down list, then you can do following: 1. include onchange event in the <select> tag, as in here: ...<select name="country" onchange="check(this.value)">... Code (markup): 3. where you want your state/county elements, create empty div with some id, as in here: <div id="state_county"></div> Code (markup): 2. include following function in the head tag, function check(x) { if (x=="USA") { document.getElementById("state_county").innerHTML='...your code to display state field...' } else { document.getElementById("state_county").innerHTML='...your code to display county filed...' } } Code (markup):