Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try using <a href="http://api.jquery.com/closest/" rel="nofollow"><code>.closest()</code></a> instead of <code>.parents()</code>. Also, you don't have a class named "partNo", just an input under the td with class "partNumber" (maybe try <code>$('.partNumber input').keyup(...);</code></p> <p>Also, you may want to look into <a href="http://php.net/manual/en/function.json-encode.php" rel="nofollow"><code>json_encode</code></a> and populate the fields with a single query to script.php instead of a couple of loads. You could do:</p> <p>script.php</p> <pre><code>&lt;?php $partNo = $_GET['vorunr']; // perform query to gather the data and populate $dbrow header('Content-Type: application/json'); // make sure browser knows what it is echo json_encode(Array( 'desc' =&gt; $dbrow['description'], 'price' =&gt; $dbrow['price'] )); ?&gt; </code></pre> <p>then use something like</p> <pre><code>$('.partNumber input').keyup(function(){ var row = $(this).closest('.item-row'); var partNumber = $(this).val(); $.getJSON('&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;',{vorunr:partNumber},function(data,textStatus,xhr){ $('.description input',row).val(data.desc); $('.price input',row).val(data.price); }); }); </code></pre> <p><strong>EDITv2</strong></p> <p>Here's a sample (Self-sufficient) file you can run and see what I mean.</p> <pre><code>&lt;?php // handle the ajax query if (isset($_GET['vorunr'])) // make sure you validate this variable; I'm not doing so for the sake of demo. { header('Content-Type: application/json'); echo json_encode(Array( 'desc' =&gt; $_GET['vorunr'], 'price' =&gt; sprintf('%0.2f',rand(100,99999)/100) )); exit; } ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Ajax Sample&lt;/title&gt; &lt;!-- MAKE SURE YOU DON'T USE THIS REFERENCE IN PRODUCTION --&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="Text/javascript"&gt; $(document).ready(function(){ $('.partNumber input').keyup(function(){ var row = $(this).closest('.item-row'); var partNumber = $(this).val(); $.getJSON('&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;',{vorunr:partNumber},function(data,textStatus,xhr){ $('.description input',row).val(data.desc); $('.price input',row).val(data.price); }); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;table&gt; &lt;tr class="item-row"&gt; &lt;td class="partNumber"&gt;&lt;input type="text" name="partNo"&gt;&lt;/input&gt;&lt;/td&gt; &lt;td class="description"&gt;&lt;input type="text" name="description"&gt;&lt;/input&gt;&lt;/td&gt; &lt;td class="price"&gt;&lt;input type="text" name="price"&gt;&lt;/input&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr class="item-row"&gt; &lt;td class="partNumber"&gt;&lt;input type="text" name="partNo"&gt;&lt;/input&gt;&lt;/td&gt; &lt;td class="description"&gt;&lt;input type="text" name="description"&gt;&lt;/input&gt;&lt;/td&gt; &lt;td class="price"&gt;&lt;input type="text" name="price"&gt;&lt;/input&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr class="item-row"&gt; &lt;td class="partNumber"&gt;&lt;input type="text" name="partNo"&gt;&lt;/input&gt;&lt;/td&gt; &lt;td class="description"&gt;&lt;input type="text" name="description"&gt;&lt;/input&gt;&lt;/td&gt; &lt;td class="price"&gt;&lt;input type="text" name="price"&gt;&lt;/input&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload