Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8852857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:30:20+00:00 2026-06-14T13:30:20+00:00

I have combo box which needs to be displayed based on the option i

  • 0

I have combo box which needs to be displayed based on the option i select,

but when i set display none to div it is not getting hidden. what could be the problem.

below is the html code and java script

<div id="addBanks" style="display: none" style="overflow: auto;height: 75%">
                        <table id="commonBodyTable" border="0" cellspacing="0" cellpadding="0" align="center">
                            <tr>
                                <td>
                                    <table width="100%" align="center" class="tableBorder2" border="0" cellpadding="2" cellspacing="0">
                                        <tr>
                                            <td colspan="4" class="mainheader">Add Banks</td>
                                        </tr>
                                        <tr class="darkrow">
                                            <td width="30%" class="textalign">Bank Code</td>
                                            <td width="5%" class="mandatory">*</td>
                                            <td width="65%" colspan="2" class="textfieldalign" ><input type="text" class="textbox" name="bankcode" id="bankcode" maxlength="20"  /></td>

                                        </tr>
                                        <tr class="lightrow">
                                            <td width="30%" class="textalign">Bank Name</td>
                                            <td width="5%" class="mandatory">*</td>
                                            <td width="65%" colspan="2" class="textfieldalign" ><input type="text" class="textbox" name="bankname" id="bankname" maxlength="20"  /></td>

                                        </tr>
                                        <tr class="darkrow">
                                            <td width="30%" class="textalign">Branch Code</td>
                                            <td width="5%" class="mandatory">*</td>
                                            <td width="65%" colspan="2" class="textfieldalign" ><input type="text" class="textbox" name="branchcode" id="branchcode" maxlength="20"  /></td>
                                        </tr>
                                        <tr class="lightrow">
                                            <td width="30%" class="textalign">IFSC Code</td>
                                            <td width="5%" class="mandatory">*</td>
                                            <td width="65%" colspan="2" class="textfieldalign" ><input type="text" class="textbox" name="ifsccode" id="ifsccode" maxlength="20"  /></td>
                                        </tr>
                                        <tr class="darkrow">
                                            <td width="30%" class="textalign">Country</td>
                                            <td width="5%" class="mandatory">*</td>
                                            <td width="65%" class="textfieldalign"><select class="combobox" name="countryid" id="countryid" onchange="getStates(this.value)">
                                                    <option value="" >- - - Select Country Name - - -</option>
                                                </select></td>
                                        </tr>
                                        <tr class="lightrow">
                                            <td width="30%" class="textalign">State</td>
                                            <td width="5%" class="mandatory">*</td>
                                            <td width="65%" class="textfieldalign"><select class="combobox" name="stateid" id="stateid">
                                                    <option value="" >- - - Select State Name - - -</option>
                                                </select></td>
                                        </tr>
                                        <tr class="darkrow">
                                            <td width="30%" class="textalign">District Name</td>
                                            <td width="5%" class="mandatory">*</td>
                                            <td width="65%" colspan="2" class="textfieldalign" >
                                                <select class="combobox" name="districtid" id="districtid">
                                                    <option value="" >- - - Select District Name - - -</option>
                                                </select></td>
                                        </tr>
                                        <tr class="lightrow">
                                            <td width="30%" class="textalign">Town or Village</td>
                                            <td width="5%" class="mandatory">*</td>
                                            <td width="65%" colspan="2" class="textfieldalign">
                                                Town <input   type="radio" class="textbox" name="optTownOrVillage" id="optTownOrVillage" value="townOpt" onclick="enableVillageOrTown(this)"/>
                                                Village <input type="radio" class="textbox" name="optTownOrVillage" id="optTownOrVillage" value="villageOpt" onclick="enableVillageOrTown(this)"/>
                                            </td>
                                        </tr>
                                        <div id="villageDiv" style="display: none;">
                                            <tr class="darkrow">
                                                <td width="30%" class="textalign">Village Name</td>
                                                <td width="5%" class="mandatory">*</td>
                                                <td width="65%" colspan="2" class="textfieldalign" >
                                                    <select class="combobox" name="villageid" id="villageid">
                                                        <option value="" >- - - Select Village Name - - -</option>
                                                    </select></td>
                                            </tr>
                                        </div>

                                        <tr class="darkrow">
                                            <div id="townDiv" style="display: none;">
                                                <td width="30%" class="textalign">Town Name</td>
                                                <td width="5%" class="mandatory">*</td>
                                                <td width="65%" colspan="2" class="textfieldalign" >
                                                    <select class="combobox" name="townid" id="townid">
                                                        <option value="" >- - - Select Town Name - - -</option>
                                                    </select></td>
                                            </div>
                                        </tr>


                                        <tr class="darkrow">
                                            <td width="30%" class="textalign">&nbsp;</td>
                                            <td width="5%" class="mandatory">&nbsp;</td>
                                            <td width="65%" colspan="2" class="textfieldalign" ><input type="button" class="submitbu" name="save" id="save" value="Save" onclick="saveState()">
                                                    <input type="button" class="submitbu" name="cancel" id="cancel" value="Cancel" onclick="cancelAddState();"></td>
                                                        </tr>
                                                        </table>
                                                        </td>

                                                        </tr>
                                                        </table>
                                                        </div>

and my java script :

function enableVillageOrTown(opt){
                var optionValue = opt.value;
                if(optionValue=='townOpt'){
                     document.getElementById("townDiv").style.display = "";
                     document.getElementById("villageDiv").style.display = 'none';
                }
                if(optionValue=='villageOpt'){
                     document.getElementById("villageDiv").style.display = "";
                     document.getElementById("townDiv").style.display = 'none';
                }

            }

UPDATE :

<div id="villageDiv" style="display: none;">
                                            <tr class="darkrow">
                                                <td width="30%" class="textalign">Village Name</td>
                                                <td width="5%" class="mandatory">*</td>
                                                <td width="65%" colspan="2" class="textfieldalign" >
                                                    <select class="combobox" name="villageid" id="villageid">
                                                        <option value="" >- - - Select Village Name - - -</option>
                                                    </select></td>
                                            </tr>
                                        </div>

also this is not properly aligned when

<tr class="lightrow">
                                            <td width="30%" class="textalign">Town or Village</td>
                                            <td width="5%" class="mandatory">*</td>
                                            <td width="65%" colspan="2" class="textfieldalign">
                                                Town <input   type="radio" class="textbox" name="optTownOrVillage" id="optTownOrVillage" value="townOpt" onclick="enableVillageOrTown(this)"/>
                                                Village <input type="radio" class="textbox" name="optTownOrVillage" id="optTownOrVillage" value="villageOpt" onclick="enableVillageOrTown(this)"/>
                                            </td>
                                        </tr>

this is not hidden when the page first time loads

Please help me to find the problem

Regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T13:30:22+00:00Added an answer on June 14, 2026 at 1:30 pm

    Try this code, if it works for you

    function enableVillageOrTown(opt){
                    var optionValue = opt.value;
                    if(optionValue=='townOpt'){
                         document.getElementById("townDiv").style.display = "";
                         document.getElementById("villageDiv").style.display = "none";
                    }
                    if(optionValue=='villageOpt'){
                         document.getElementById("villageDiv").style.display = "";
                         document.getElementById("townDiv").style.display = "none";
                    }
    
                }
    

    For that your should use this code for HTML

    <!--<div >-->
                                                <tr class="darkrow" id="villageDiv" style="display: none;">
                                                    <td width="30%" class="textalign">Village Name</td>
                                                    <td width="5%" class="mandatory">*</td>
                                                    <td width="65%" colspan="2" class="textfieldalign" >
                                                        <select class="combobox" name="villageid" id="villageid">
                                                            <option value="" >- - - Select Village Name - - -</option>
                                                        </select></td>
                                                </tr>
                                            <!--</div>-->
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a combo box in which I have to display the dates from
I have this form, in which i need to populate a combo box with
I have a form which has a Combo Box Control. I have selected the
I have a maximized form which has Combo-Box control (docked in top-right) with 500px
I have return cellvaluechanged event for my column1 which contains the category combo box.if
I am building a form in access database. I have a combo box which
I have a dynamic combo box which has the URL as the value. I
I have a Delphi application A, which needs to select a certain item in
I have a combo box which is of a lookup type, i.e., I've selected
I have a webpage with a combo box on the page which is loaded

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.