hi all

i have list box with multi select options.
I  can add new item dynamically in the list box by using ADD OPTION

ways to Delete the Items:
 1). i can delete all the items in the list box by using DELETE ALL
 2). Select the specified item and delete by using DELETE

THE PROBLEM I FACING:
  i select all items in the list box and if i press DELETE it will give
Dr. watson Erron when i invoke this page in IE

 but the Same Code is WORKING fine in NETSCAPE


my code:
<html>
<head>
<script Language="Javascript">
     function fnAddData(){
 len=document.group.select1.length
 document.group.select1.options[len] = new Option(document.group.txtName.value)
 document.group.select1.options[len].value = document.group.txtName.value
 }

     function fnAllDelete(){
 document.group.select1.length=0
 }

     function checkArraySize(){
 selectLength=document.group.select1.length
 arrayLength =getSelectedArrayIndex()
              if (selectLength==arrayLength){
            fnAllDelete()
  }
     else{
  fnDelete()
  }

 }

     function getSelectedArrayIndex(){
 var count=0
 for(i=0;i<document.group.select1.length;i++){
       if(document.group.select1.options[i].selected) count++
  }
 return count;
 }
 function fnDelete(){
  listArray = new Array()
  indexArray = new Array()
  var count=0
  var arcount=0
  for(i=0;i<document.group.select1.length;i++)
   {
   if (!(document.group.select1.options[i].selected))
    {
    listArray[count] = document.group.select1.options[i].value
    count++
   }
     else
   {
        indexArray[arcount] = i
     arcount++
   }
   }


  for(i=indexArray.length-1;i>=0;i--)
   {
    document.group.select1.options[indexArray[i]] = null
   }


 }


</script>
</head>

<body>

<form name="group">
  <p><select id="select1" name="select1" style="HEIGHT: 56px; WIDTH: 111px" multiple
  size="5">
  </select> <input type="text" name="txtName" size="20"> <input type="button" 
value="Add"
  name="cmdAdd" onClick=" fnAddData()"><input id="cmdDelete" name="cmdDelete" 
type="button"
  value="Delete" onClick="checkArraySize()"><input type="button" value="DeleteAll"
  name="cmdDeleteAll" onClick=" fnAllDelete()"></p>
</form>
</body>
</html>












thanks in advance
alagu

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to