Removing options in select tag

Posted on 2004-09-25
Last Modified: 2008-01-09
   I have this code in my  javascript ...this is part of tht..  
  //this I used to remove options ..
  var totalopts = document.frmApplication.department.length;
                  alert("total to remove "+totalopts);
           //code for removing all the early options
           var opt = new Option("<--Select Department-- >","0");
      //this is for adding new options    
                     var j=1;      
                        var opt = new Option(DEPT[i],DEPTID[i]);
            But next time I m calling this function ,
                  options are not going to remove ...
                  First time it is removing as there is no options in it ,,
            Plz help me..
Question by:Manish
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 25

Expert Comment

ID: 12150276
try this:
function remAllOpt()
LVL 25

Accepted Solution

devic earned 125 total points
ID: 12150282
or this:
function remAllOpt()
LVL 11

Author Comment

ID: 12150455
Thanks devic .....grt..!

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question