Hello,

I have this anomaly on a website I support. There is a button that allows users to contacts from a contact list. The button works fine in other browsers, and has worked fine in the past for Google Chrome. Someone notified me that in Chrome the button no longer does what's expected and instead the entire button disappears instead of removing the contacts from the list.

How do I even go about debuggin this and is this a known problem?

Thank you

Can you provide a link to this website so that we can look at the source code or provide the relavent code here by posting it, or upload the code to jsfiddle.

This is the code for the form itself and the button.

<form method="post" name="recipForm" id="recipForm" onSubmit="return false();">
<span style="cursor: help; font-weight: bold;" onMouseOver="tooltip(currtip);" onMouseOut="bye();">
Current Recipient List</span>
<table cellpadding="2" cellspacing="0" border="0">
<tr>
<td>
<select name="sendTo[]" size="5" id="sendTo" multiple="multiple">
<option value="IDENTIFICATION, something@blank.com">Person - Person - Email</option></select>
</form>
<input type="button" value="Remove Selected Recipients" onClick="remove();"/><br/>
<input type="button" value="Save Current Recipient List" onClick="saverecip();"/>

This is the code for the javascript for remove and saverecip...

function remove(){
    var st = document.getElementById('recipForm').sendTo;
    for(i=0;i<st.length;i++){
        if(st[i].selected){
            st[i] = null;
            i--;
        }
    }
}


function saverecip(){
    var st = document.getElementById('recipForm').sendTo;
    var save = document.getElementById('saveList').save;

    for(i=0;i<save.length;i++){
        save[i] = null;
        i--;
    }

    for(i=0;i<st.length;i++){
        save.options[save.length] = new Option(st[i].text,st[i].value);
    }

    for(i=0;i<save.length;i++){
        save[i].selected = true;
    }

    document.getElementById('saveList').submit();
}

well, it looks like the function you called "remove()" is already the name of a method in JavaScript. Why it works in IE...well as you may be aware, IE doesnt necessarily follow the W3C standards all the time. When I rename it to removeMe() and also update the name to removeMe() in the onclick reference, the item is removed from the select element as expected.

Also, this may be a simplier function to use to remove items from a select element...

function removeMe(){
    var x=document.getElementById("sendTo");
    x.remove(x.selectedIndex);
}

Simple full example...

<!DOCTYPE html>
<html>
<body>
<select id="sendTo" multiple="multiple">
<option value="1">Item 1</option>
<option value="2">Item 2</option>
<option value="3">Item 3</option>
<option value="4">Item 4</option>
<option value="5">Item 5</option></select>

<br/>
<input type="button" value="Remove Selected Recipients" onclick="removeMe();"/>

<script>
function removeMe(){
    var x=document.getElementById("sendTo");
    x.remove(x.selectedIndex);
}
</script>
</body>
</html>

Thank you very much for the explanation!!! I will do this first thing in the morning at work tomorrow!!! I didn't write the code; and I recently became the steward of the site.

It's strange because it works in both IE, and Firefox!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.