I need to to hide a field"addr_state1" based on a value in the drop down list field called "addr_country".i.e.,if addr_country.value=="in" then hide addr_state1 else , and if the value in the selection changes to something else then show the field addr_state1. Also the addr_state1 should be hidden when the page loads with value "IN", and if the page loads some other value than show the addr_state1 field.
Code used for this is :(I have to add this code to an CRM software. where i have to hide the field conditionally)
Expand|Select|Wrap|Line Numbers
- <script>
- window.attachEvent("onload",hidefield);
- window.attachEvent("onchange",hidefield1);
- function hidefield()
- {
- if(document.getElementById("addr_country").value=='IN')
- {
- document.getElementById("addr_state1").style.visibility=hidden;
- }
- }
- function hidefield1()
- {
- if(document.getElementById("addr_country").value!='IN')
- {
- document.getElementById("addr_state1").style.visibility=visible;
- }
- else
- {
- document.getElementById("addr_state1").style.visibility=hidden;
- }
- </script>