I'm trying to have it so that upon the start of a function an "oldvalue" is created that is based on the contents of a text field, since I want certain textfields to be updated automatically until edited. So the thought behind it is that I compare the oldvalue to the value currently in the textbox that is editable and if they don't match, to stop editing that field. However when I define the oldvalue based on a non-editable textbox it keeps updating when that box is changed automatically. In other words, how do I stop a value from updating after first setting it?
function DescChanged() {
desc = document.getElementById("Txb_Description");
input = document.getElementById("Txb_WebArtName");
kortinput = document.getElementById("KortBesc");
langinput = document.getElementById("LangBesc");
merk = document.getElementById("Brand");
bestelnr = document.getElementById("Txb_ArticleOrderNr");
const inputold = input;
With this if clause:
if (kortinput.value == inputold.value || isEmptyOrSpaces(kortinput.value))
Try having a variable outside the function, and use a temporary variable within the function, as:
var inputold = "";
function DescChanged() {
desc = document.getElementById("Txb_Description");
input = document.getElementById("Txb_WebArtName");
kortinput = document.getElementById("KortBesc");
langinput = document.getElementById("LangBesc");
merk = document.getElementById("Brand");
bestelnr = document.getElementById("Txb_ArticleOrderNr");
// check if values are equal
if (kortinput.value == inputold.value || isEmptyOrSpaces(kortinput.value))
const inputold = input; // update the oldvalue
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.