1 Replies - 197 Views - Last Post: 11 July 2019 - 07:34 AM

#1 DarenR   User is offline

  • D.I.C Lover

Reputation: 616
  • View blog
  • Posts: 4,104
  • Joined: 12-January 10

javascript function is undefined

Posted 11 July 2019 - 06:50 AM

i have a javascript function which is stating it is undefined. it is identical to the other functions i have except the name


here is the error:
Line: 452
Error: 'fnFeedstockBLKOnHandCheck' is undefined



here are the items for the function:

  <asp:textbox id="txtBLK_On_Hand" runat="server"  Text='<% #Eval("BLK_On_Hand") %>'  CssClass="DataGridTextNumeric" onchange="javascript:return fnFeedstockBLKOnHandCheck(this, 'OHBLK');" Width="80px"></asp:textbox>
                                         




script:
function fnFeedstockBLKOnHandCheck(txtControl, inControl) {
    var gRow = txtControl.parentNode.parentNode;
    if ((isNaN(txtControl.value)) || (txtControl.value == '') || (txtControl.value < 0)) {
        txtControl.focus();
        if (inControl == 'OHBLK') {

            alert('Please enter valid OnHand Tons');
            gRow.cells[3].getElementsByTagName("input")[0].value = 0;

            return false;
        }

    }

    var OHBLK = parseFloat(gRow.cells[3].getElementsByTagName("input")[0].value.replace(',', ''));

    var rmBLKExist = parseFloat(gRow.cells[6].getElementsByTagName("input")[0].value.replace(',', ''));
    var rmBLK = gRow.cells[6].getElementsByTagName("input")[0];

    var remainingBLK = (rmBLKExist + OHBLK);
    if (isNaN(remainingBLK) && isNaN(OHBLK)) {
        remainingBLK = 0;
    }
    else if (isNaN(remainingBLK) && !isNaN(OHBLK)) {
        remainingBLK = OHBLK;

    }
    rmBLK.value = remainingBLK.toFixed(2);

    return true;
}






now here is the items that work:
 <asp:textbox id="txtBLK_Tons_Added" runat="server"  Text='<% #Eval("BLK_Tons_Added","{0:F2}") %>'  CssClass="DataGridTextNumeric" onchange="javascript:return fnFeedstockBLKInputCheck(this,'TABLK');" Width="80px"></asp:textbox>



function fnFeedstockBLKInputCheck(txtControl, inControl) {
    var gRow = txtControl.parentNode.parentNode;
    if ((isNaN(txtControl.value)) || (txtControl.value == '') || (txtControl.value < 0)) {
        txtControl.focus();
        if (inControl == 'TABLK') {
           
            alert('Please enter valid BLK Added Tons');
            gRow.cells[4].getElementsByTagName("input")[0].value = 0;
           
            return false;
        }

    }

    var TABLK = parseFloat(gRow.cells[4].getElementsByTagName("input")[0].value.replace(',', ''));
   
    var rmBLKExist = parseFloat(gRow.cells[6].getElementsByTagName("input")[0].value.replace(',', ''));
    var rmBLK = gRow.cells[6].getElementsByTagName("input")[0];

    var remainingBLK = (rmBLKExist + TABLK);
    if (isNaN(remainingBLK) && isNaN(TABLK)) {
        remainingBLK = 0;
    }
    else if (isNaN(remainingBLK) && !isNaN(TABLK)) {
        remainingBLK = TABLK;

    } 
    rmBLK.value = remainingBLK.toFixed(2);
   
    return true;
}



if i put the working function name in the non working function call -- it does not produce an error and runs through the correct results for that calling field. however if i put the correct function it returns that error...

can any one spot why this is happening?

Is This A Good Question/Topic? 0
  • +

Replies To: javascript function is undefined

#2 DarenR   User is offline

  • D.I.C Lover

Reputation: 616
  • View blog
  • Posts: 4,104
  • Joined: 12-January 10

Re: javascript function is undefined

Posted 11 July 2019 - 07:34 AM

so to fix this -- i deleted the function then typed it in again -- exactly the same as before and the error went away

like what the f
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1