How to enable disable fields using Java Script in Webform

trosermasuase

New Member
I have created a web page "Default.aspx" in which I have taken fields: First Name, Last Name, Account Titling, Titling(radio button list), AccountNumber and AccountFormatunder the "Default.aspx" page, I have used a radio button list also, whose values are Yes and No. If I choose Yes, then the following fields visibility should set to false:First Name, Last NameIf I choose "NO", then the following fields visibility should set to true:Account Titling, Account numberFor this, I have written the below Java Script code in "Default.aspx"\[code\]function EnableDisableTaxID() { if (document.getElementById("<%=rdOpeningSubAccount.ClientID %>") != null) { var openSubAccountList = document.getElementById('<%= rdOpeningSubAccount.ClientID %>'); var fbo1RadioList = document.getElementById('<%=fbo1RadioButtonList.ClientID %>').value; var isOpenSubAccount; if (openSubAccountList != null) { var openSubAccount = openSubAccountList.getElementsByTagName("input"); for (var i = 0; i < openSubAccount.length; i++) { if (openSubAccount.checked) { isOpenSubAccount = openSubAccount.value; alert("Print" + isOpenSubAccount); } } } alert(typeof(isOpenSubAccount)); if (isOpenSubAccount == 'true') { FirstName.visible = true; LastName.visible = false; AccountTitling.visible = true; lblFirstName.visible=false; lblLastName.visible=false; } else if (isOpenSubAccount == 'false') { AccountTitling.visible = true; AccountNumber.visible = false; lblAccountTitling.visible = true; lblAccountNumber.visible = false; } } }\[/code\]However, I am getting the required value from the Radio button list, however, when I go to check if the selected value of the radiobuttonlist is true, then the code above does not work. I dont know what am I missing. I know that directly using the below code will not work:\[code\]if (isOpenSubAccount == 'true') { FirstName.visible = true; LastName.visible = false; AccountTitling.visible = true; lblFirstName.visible=false; lblLastName.visible=false; }\[/code\]Please help as I m stuck here...
 
Back
Top