[Javascript] How do I delete and option or element from a drop down

Scott.Wiseman swiseman at remax-cahi.com
Mon Jul 8 21:19:56 CDT 2002


//=================================================================
//==============LOAD ALL AGENTS INTO DROP DOWN=====================

//=================================================================
function AllAgentList()
{
!!!!!!!!!!!!!!! this is not delete the box...It leaves spaces openned
//=================================================================
//=============DELETE ELEMENTS IN SELECT BOX=======================

//=================================================================
       document.myform.associatecount.value=0;
		for(i=0;  i<document.myform.salesagents.length ;i++)
		{
          		document.myform.salesagents.options[i]= null;
		}
		document.myform.salesagents.length = 0;
//=================================================================
//=============LOAD first option with select=======================

//=================================================================
           document.myform.salesagents.options[0]             =  new
Option(0);   
           document.myform.salesagents.options.selectedIndex  = 0; 
           document.myform.salesagents.options[0].text        =   "Select
ALL Agent";             
//=================================================================
//=============LOAD DROP DOWN BOX WITH AGENTS======================

//=================================================================
   for(var x=1; x< LoadAgents1.length; x++)
      {
           document.myform.associatecount.value               =
document.myform.associatecount.value + 1;
           document.myform.salesagents.options[x]             =  new
Option(x);   
           document.myform.salesagents.options[x].value       =
LoadAgents0[x];  
           document.myform.salesagents.options[x].text        =
LoadAgents1[x] + " - " + LoadAgents2[x] ; 
     }  
}




More information about the Javascript mailing list