J'ai une boîte de sélection déroulante dans un div. Lorsque l'utilisateur clique sur le changement, une liste déroulante apparaît à côté du bouton Modifier/Soumettre et l'utilisateur fait une sélection qui met alors à jour la base de données et la sélection apparaît à la place du menu déroulant. Tout fonctionne très bien dans IE8 et firefox mais dans IE7 il permet une sélection (il y a plusieurs listes déroulantes identiques) mais la seconde fois qu'une sélection est faite il se bloque s'il vous plaît attendez. Ceci est le code correspondantjavascript select box suspendu à la deuxième sélection dans ie7
<td width=200>
<input type="button" onclick="startChanging(this)" value="Change" /></td>
<script type="text/javascript">
var selectBox, isEditing = false;
var recordvalue;
if(window.XMLHttpRequest) {
recordvalue = new XMLHttpRequest();
} else if(window.ActiveXObject) {
try {
recordvalue = new ActiveXObject('Microsoft.XMLHTTP');
} catch(e) {}
}
window.onload = function() {
selectBox = document.getElementById('changer');
selectBox.id = '';
selectBox.parentNode.removeChild(selectBox);
};
function startChanging(whatButton) {
if(isEditing && isEditing != whatButton) { return; } //no editing of other entries
if(isEditing == whatButton) { changeSelect(whatButton); return; } //this time, act as "submit"
isEditing = whatButton;
whatButton.value = 'Submit';
var theRow = whatButton.parentNode.parentNode;
var stateCell = theRow.cells[3]; //the cell that says "present"
stateCell.className = 'editing'; //so you can use CSS to remove the background colour
stateCell.replaceChild(selectBox,stateCell.firstChild); //PRESENT is replaced with the select input
selectBox.selectedIndex = 0;
}
function changeSelect(whatButton) {
isEditing = true; //don't allow it to be clicked until submission is complete
whatButton.value = 'Change';
var stateCell = selectBox.parentNode;
var theRow = stateCell.parentNode;
var editid = theRow.cells[0].firstChild.firstChild.nodeValue; //text inside the first cell
var value = selectBox.firstChild.options[selectBox.firstChild.selectedIndex].value; //the option they chose
selectBox.parentNode.replaceChild(document.createTextNode('Please wait...'),selectBox);
if(!recordvalue) {
//allow fallback to basic HTTP
location.href = 'getupdate.php?id='+editid+'&newvalue='+value;
} else {
recordvalue.onreadystatechange = function() {
if(recordvalue.readyState != 4) { return; }
if(recordvalue.status >= 300) { alert('An error occurred when trying to update'); }
isEditing = false;
newState = recordvalue.responseText.split("|");
stateCell.className = newState[0];
stateCell.firstChild.nodeValue = newState[1] || 'Server response was not correct';
};
recordvalue.open('GET', "getupdate.php?id="+editid+"&newvalue="+value, true);
recordvalue.send(null);
}
}
</script>
Si quelqu'un a une idée pourquoi cela arrive je serais très reconnaissant