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

  • Home
  • SEARCH
  • 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 1042011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:26:26+00:00 2026-05-16T15:26:26+00:00

I have a code that fetches a list from DB. Using that returned array

  • 0

I have a code that fetches a list from DB. Using that returned array i am creating a grid table and two combo boxes dynamically. Now, the code is working fine for first time. I can also able to add new entry to the database and show it in the grid. Now the problem is with the combo box.

Whenever i add a new entry, the table gets updated by deleting the previous content in the table and fetching again from the DB along with new entry. But the combo options get appended with the newly arrived data. See, the image. Chemical Engg is newly addded.alt text

But i dont know to reset or delete existing combo box contents. I know that the solution is a piece of code that makes the combo box null. It has to be placed on the top of combo box generation code. So, that it ll reset every time before generating new elements.

My question is how to make that combo box null in the starting point.(I dont know what exact term is “null” or “reset”, i new to DOM elements).

Here my Code.

The HTML ELEMENT:

<select id="departmentField" >//Both using same data source. 
<select id="searchDepartments">

The Script:
Its DWR Call… I think the problem comes below the grid.

    EmployeeManagement.getDeptList(function(deptRecords) {
    $("#depts").clearGridData(true);
    $("#depts").jqGrid('addRowData', "deptID", deptRecords);

    var deptSearchSelect = document.getElementById('searchDepartments');
    var searchOptions = null;
    searchOptions = document.createElement('option');
    searchOptions.value = 0;
    searchOptions.innerHTML = "ALL";
    deptSearchSelect.appendChild(searchOptions);

    var depFieldSelect = document.getElementById('departmentField');
    var deptFieldOpts = null;
    deptFieldOpts = document.createElement('option');
    deptFieldOpts.value = 0;
    deptFieldOpts.innerHTML = "";
    depFieldSelect.appendChild(deptFieldOpts);

    for(i = 0; i<deptRecords.length; i++) { 


        var dept = deptRecords[i];
        searchOptions = document.createElement('option');
        searchOptions.value = dept.deptID;
        searchOptions.innerHTML = dept.deptName;
        deptSearchSelect.appendChild(searchOptions);

        deptFieldOpts = document.createElement('option');
        deptFieldOpts.value = dept.deptID;
        deptFieldOpts.innerHTML = dept.deptName;
        depFieldSelect.appendChild(deptFieldOpts);

    }

    deptSearchSelect.selectedIndex = "ALL";
    deptSearchSelect.selectedIndex = "";

    //var respDiv = document.getElementById("respCheck");
});

How shall i reset?

Any suggestions would be more appreciative

Thanks in advance!!!

  • 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-05-16T15:26:27+00:00Added an answer on May 16, 2026 at 3:26 pm

    Try deleting each element in the select:

    while(deptSearchSelect.hasChildNodes()) {
        deptSearchSelect.removeChild(deptSearchSelect.firstChild);
    }
    while(depFieldSelect.hasChildNodes()) {
        depFieldSelect.removeChild(depFieldSelect.firstChild);
    }
    

    Are you also not able to set the select box properly?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 545k
  • Answers 545k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think you could do something like this: SELECT Sum(stuff)… May 17, 2026 at 8:55 am
  • Editorial Team
    Editorial Team added an answer I have found that I was pretty snookered with the… May 17, 2026 at 8:55 am
  • Editorial Team
    Editorial Team added an answer Well, since I haven't found a compelling answer to this… May 17, 2026 at 8:55 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Following on from this question I now have code that can attach to a
I am querying information from Active Directory . I have code that works, but
I have a silverlight 3 application, that fetches some simple data from a ms-sql-server
I have code that references a web service, and I'd like the address of
I have code that looks like the following, which works fine for displaying the
I have code that looks like: //System.Data.IDataRecord dr try { Consolidated = Utility.NullConvert.ToBool(dr[Constants.Data.Columns.cConsolidated], false);
Right now, I have code that looks something like this: Private Sub ShowReport(ByVal reportName
Hashtables have a syncroot property but generic dictionaries don't. If I have code that
I have some code that gives a user id to a utility that then
I have this code that performs an ajax call and loads the results into

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.