PROBLEM adding new row in form JQUERY
so the idea is to add a row with an inputfield each time the
inputfield "naam" is filled in.
fore some reason it only adds a new row when i adjust the content of
row 1. I figure that the script actualy does what i ask, because it add's a new row when i fill in "naam" the first time. The probem is that i don't say that he has to look to the following inputfield. But i don't know how to do so. So are there any ideas ?
a live example is to be found here
http://www.hablahabla.be/j
-
$(function() {
$(".naam").keyup(function () {
// json aanroepen
$.getJSON("producten.js", function(json) {
var PrijsGezochteNaam = $(".naam").val();
$.each(json.channel.items,function(i,item) {
if (json.channel.items[i].naam == PrijsGezochteNaam) {
// index=i; alert(index);
PrijsGezochteNaam= json.channel.items[i].prijs;
$(".prijs").val(PrijsGezochteNaam);
var nieuwerij =
$("<tr class='delijn'>"
+ "<td><input type='text' class='naam' /></td>"
+ "<td><input type='text' class='aantal' value='1' /></td>"
+ "<td><input type='text' class='prijs' disabled='true' /></
td>"
+"</tr>");
$(nieuwerij).appendTo(".prijslijst tbody");
}
}); // end each json
}); // end json
});// end keyup
}); // and document.ready
</script>
</head>
<body>
<form action="" method="" accept-charset="utf-8">
<table class="prijslijst" border="1">
<thead>
<th>Naam</th>
<th>Aantal</th>
<th>Eenheidsprijs</th>
<th>Subtotaal</th>
</thead>
<tbody>
<tr class="delijn">
<td><input type="text" class="naam" /></td>
<td><input type="text" class="aantal" value="1"/></td>
<td><input type="text" class="prijs" disabled="true" /></td>
<td><input type="text" class="subtotaal" disabled="true" /></
td>
</tr>
</tbody>