When updating the But2Click
function, make sure to change arrstr
to ArrStr
and indx
to Indx
.
The But2Click
function contains several errors that need to be corrected. Please see the corrected version below:
function But2Click(){
var Indx = ArrStr.indexOf(document.getElementById("TxtBox").value); // Ensure correct id for the text box
alert(Indx);
if(Indx > -1) {
ArrStr.splice(Indx,1); // Index should be passed as the first argument for the splice function
}
document.getElementById("Arr").innerHTML = ArrStr; // Correct id for the element and variable name case
}