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 516k
  • Answers 516k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You'll have to do this manually. If you want a… May 16, 2026 at 6:47 pm
  • Editorial Team
    Editorial Team added an answer RedirectMatch Permanent (.*)/vtype/sd/ $1/ May 16, 2026 at 6:47 pm
  • Editorial Team
    Editorial Team added an answer The result will be the same for both. If you… May 16, 2026 at 6:47 pm

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

I have a silverlight 3 application, that fetches some simple data from a ms-sql-server
I have compared two queries which fetch some fairly large data from a database
I have an app that currently holds all state in memory. It fetches a
I'm practicing PyQt and (Q)threads by making a simple Twitter client. I have two
Awhile ago I came across a script that basically fetched a list of countries/states
I have explained the problem below this code <div id='content'> <div id='help'> blah blah
This is related to Classic ASP code. A page fetches data for a particular
I have two tables (item and category, I think they speak for themselves) and
I have: A passive STS login application that is also an identity provider. An
I have a table of chalets where a chalet is referenced by an account...

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.