Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  
  <div class='tableWrap'>
    <table class='styled-table'>
      <thead>
        <tr>
          <th>Add</th>
          <th>DWG_NO</th>
          <th>Description</th>
          <th>Profile</th>
          <th>Pcs</th>
          <th>Length</th>
          <th>Ib_ft</th>
          <th style="width:100%;">Observation</th>
        </tr>
      </thead>
      <tbody>
    
        <tr>
          <td>
            <button type='button' onclick='dosomethingcrazy(this)'>Try</button>
          </td>
          <td>DWG_NO</td>
          <td>Description</td>
          <td>Profile</td>
          <td><textarea rows='1' cols='3' id='myTextarea' name='something'>0</textarea></td>
          <td>Length</td>
          <td>Ib/ft</td>
          <td>Observ</td>
        </tr>
        <tr>
          <form id='form1' action='insert.php' method='post'>
            <input type='hidden' id='greeting' name='test' value='one'>
            <td><button type='button' onclick='dosomethingcrazy(this)'>Try</button></td>
            <td><input type='text' name='drawingnum' placeholder='Drawing #'></td>
            <td><input type='text' name='type' placeholder='Type' required></td>
            <td><input type='text' name='profile' placeholder='profile' required></td>
            <td><input type='number' min='0' name='pieces' placeholder='0'></td>
            <td><input type='number' min='0' name='length' placeholder='0' required></td>
            <td><input type='number' min='0' name='ibft' placeholder='0' required></td>
            <td><textarea class='description' oninput = 'auto_grow(this)' type='text' name='description' value='initiate-value'></textarea></td>
          </form>
        </tr>";
      </tbody>
    </table>
  </div>
  
  <script>
    function dosomethingcrazy(a)
    {
      // mixing up php and javascript notation. 
      // javascript doesn't use '$' for variables.
        console.log('hello');
        var row = a.closest('tr');    // Find the row
        // Are you using jquery? if you are you can use find, but if not, then use querySelector.
        // If you are not using a library then use .value to get the input value.
        var text = row.querySelector('[name="drawingnum"]').value; // Find the text
        // Let's test it out
        alert(text);
    }
  </script>
</body>
</html>
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers