+ 4
Backspace delete
If the input is being given by user in html form, how to provide a single character /digit delete button.
2 Respuestas
+ 2
You'll have to find the index of the last character in the string and delete it. You could use del but you could also use splice. If you use splice, you'll need to convert it into a table first. Here's an example (some code I've written before specifically for this)
function erase(t) {
var x = document.getElementById("res");
if (t == 1) {
x.innerHTML = "0";
}
else {
var str = makeTab(x.innerHTML);
str.splice(str.length-1,1);
x.innerHTML = unwrapText(str);
}
}
+ 1
try a function like this one in the onClick of the button:
function delLastChar(){
var str = this.form.input.value;
this.form.input.value=str.substring(0, str.length - 1);}
never tested it, but hope you get the clue oft it.