Hi
I have Dropdown ModeOfPayment. I want if user selects Bank then txtAccountNo,txtAccountName should be enabled else
they should remain false
Code
Mode Of Payment
Cash
Cheque
Bank TransferThanks
Hi
I have Dropdown ModeOfPayment. I want if user selects Bank then txtAccountNo,txtAccountName should be enabled else
they should remain false
Mode Of Payment
Cash
Cheque
Bank TransferThanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Naimish MakwanaRank #324 · 7.7K reputationPosted Sep 4, 2024, 6:58 AM EDT
To achieve this functionality, you can use JavaScript to enable or disable the textboxes based on the selected value of the dropdown. Here’s an example of how you can do it:
txtAccountNoandtxtAccountNametextboxes to your form.onchangeevent to the dropdown to call a JavaScript function when the selection changes.Here’s the complete code:
Mode Of Payment Cash Cheque Bank Transfer Account Number Account Name function toggleAccountFields() { var ddlModeOfPayment = document.getElementById(''); var txtAccountNo = document.getElementById('txtAccountNo'); var txtAccountName = document.getElementById('txtAccountName'); if (ddlModeOfPayment.value == "2") { // Bank Transfer txtAccountNo.disabled = false; txtAccountName.disabled = false; } else { txtAccountNo.disabled = true; txtAccountName.disabled = true; } }This script will enable the
txtAccountNoandtxtAccountNametextboxes only when “Bank Transfer” is selected from the dropdown. Otherwise, the textboxes will remain disabled.Thanks