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

What's the point in getting elements by id if the id's are dynamic?
Instead, use a css class as the selector. Then, use the $(this).parents('tr') method to get the row in the table.

PHP Code:
 <?php foreach($rows as $row) : ?>
        <td><input type="text" name="text_one[]" class="findrow" /></td>
        <td><span class="showme"><?= $row['id'];?></span></td>
  <?php endforeach; ?>

     row = $(this).parents('tr');
     t2 = row.find('.showme').html();

After you change the value in one of the input fields, the id of the current row will be displayed in an alert box.

Messages In This Thread
RE: getElemntbyid returns undefined value - by Wouter60 - 08-29-2018, 10:59 AM

Theme © iAndrew 2016 - Forum software by © MyBB