onChange field value does not keep new value when item is saved

Hi everyone,

I have an on change event that fires when one of my stock fields are changed, which should change the value of a stock message field.

The function I have is able to change the value of the stock message field, but when I save/click done, the value is not updated in the properties.

My code:

var fMinStock = document.getElementsByName("_minimum_stock")[1].value;
var fCurrStock = document.getElementsByName("_current_stock")[1].value;
var iMinStock = parseInt(fMinStock);
var iCurrStock = parseInt(fCurrStock);
var fStockMessage = getFieldByName("_stock_message").getElementsByTagName("input")[0];
var stockMsg = "";
var stockMsgColor = "";
if(iCurrStock < iMinStock){
    stockMsg = "Insufficient Stock";
    stockMsg = "Sufficient Stock";
fStockMessage.value = stockMsg;

The onChange in action:

When save or done is clicked after onChange:

Any ideas on what I might be doing wrong?