0 Replies - 591 Views - Last Post: 08 April 2019 - 09:20 AM Rate Topic: -----

#1 DarenR   User is offline

  • D.I.C Lover

Reputation: 624
  • View blog
  • Posts: 4,170
  • Joined: 12-January 10

is there a way to set the value of a dynamic textbox using javascript

Posted 08 April 2019 - 09:20 AM

i have to use javascript to set a value of a text box that lives in a gridview which is created dynamically.

the reason i need to add the value to the text box is because we need to save the value to a database that lives in that text box

here is code i made that adds value to the text box but when you look at the actual text box its value is 0
you can see in the image there is value in the text box however the actual value in the text box is 0?



<input name="ctl00$phBody$tcUptime$TabpanelwIP$gvWIP$ctl03$txtWIPBLK_RemainingOnHand" type="text" value="0.00" readonly="readonly" id="ctl00_phBody_tcUptime_TabpanelwIP_gvWIP_ctl03_txtWIPBLK_RemainingOnHand" class="DataGridTextNumeric" onkeypress="return fncInputPositiveDecimal();">



javascript code:

unction fnWIPBLKInputCheck(txtControl, inControl) {
    if ((isNaN(txtControl.value)) || (txtControl.value == '') || (txtControl.value < 0)) {
        txtControl.focus();
        if (inControl == 'TAWIPBLK') {
            alert('Please enter valid grade on hand');
            return false;
        }

        if (inControl == 'CSWIPBLK') {
            alert('Please enter valid production tons');
            return false;
        }
    }

    var gRow = txtControl.parentNode.parentNode;

    var TABLK = parseFloat(gRow.cells[3].getElementsByTagName("input")[0].value.replace(',', ''));
    var CSBLK = parseFloat(gRow.cells[4].getElementsByTagName("input")[0].value.replace(',', ''));
    //var rmBLK = gRow.cells[5];
    var rmBLK = gRow.cells[5].getElementsByTagName("input")[0];

    var remainingBLK = (TABLK - CSBLK);
    if (isNaN(remainingBLK) && isNaN(TABLK)) {
        remainingBLK = 0;
    }
    else if (isNaN(remainingBLK) && !isNaN(TABLK)) {
        remainingBLK = TABLK;

    } 

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

Attached image(s)

  • Attached Image


Is This A Good Question/Topic? 0
  • +

Page 1 of 1