Welcome Guest, Not a member yet? Register   Sign In
getElemntbyid returns undefined value

(08-28-2018, 12:21 AM)kvanaraj Wrote:
(08-27-2018, 11:36 PM)Vitaly83 Wrote:
(08-27-2018, 01:49 AM)kvanaraj Wrote: var txtSecondNumberValue = document.getElementById('texttwo_'+rowid).value;
return indefined value in javascript. but in the POST values working . need suggestion

Display 'texttwo_'+rowid result and check if this element exists. Using of jQuery and other libs will not help if the element with this ID is not exists.

Just call console.log('texttwo_'+rowid) before call document.getElementById to check what element you try to get.

If document.getElementById returns null, then that element is not exists or hasn't created yet if it is a dynamical element.
It returns  texttwo_1 or texttwo_2
Yes it's a dynamical element
it's a input type 
echo '<td id="texttwo_'.$row['id'].'"> 
  <input type="number" min="0" max="999" name="acr"  
  onChange="sum('.$row['id'].');" class="txtbox"  ></td>';
It is a muliple  row. each row has different value that should be calculated based on this second row

If they're dynamical and create on document load then run you code in:

document.addEventListener("DOMContentLoaded", () => {
    // TODO: your code here

or if you use jQuery in:

$(document).ready(() => {
    // TODO: your code here

Messages In This Thread
RE: getElemntbyid returns undefined value - by Vitaly83 - 08-29-2018, 08:38 AM

Theme © iAndrew 2016 - Forum software by © MyBB