Na wstępie powiem że jestem zielony z AJAX/JavaScript - posklejałem z różnych przykładów i zrobiłem dynamiczne dodawanie pozycji.
Kod
<HTML><HEAD><TITLE>Przykład</TITLE>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
<BODY id=page>
<script type="text/javascript">
$(document).ready(function() {
$('#dodajWiersz').click(function() {
var liczba = $('#tabela tr').length;
var f1 = '<td><input type="text" class="medium" name="pozycja[]"/></td>';
var f2 = '<td><input type="text" class="medium" name="typ[]"/></td>';
var f3 = '<td><a class="delete" href="#">Usuń wiersz</a></td>';
var row = '<tr class="none" id="wiersz-'+liczba+'"><td>'+liczba+'</td>'+f1+f2+f3+'</tr>';
$('#tabela').find('tbody').append(row);
$('tr.none').removeClass('none').animate({'backgroundColor':'#66B04D','color':'#fff'},300,function(){
$(this).animate({'backgroundColor':'#fff','color':'#000'},300);
});
});
$('.delete').live('click',function() {
$(this).closest('tr').animate({'backgroundColor':'#EF3E23','color':'#fff'},300,function(){
$(this).remove();
$('#tabela > tbody > tr').each(function(i) {
$(this).find('td:first-child').text(i+1);
});
});
});
});
</SCRIPT>
<p><a href="#" id="dodajWiersz" class="add">Dodaj nowy wiersz</a></p>
<form action=index2.php method=post>
<table id="tabela">
<thead>
<tr>
<th>Lp.</th>
<th>Nazwa</th>
<th>Typ</th>
<th>Akcje</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<INPUT class=submit input type="submit" name="submit" value=" Zatwierdz ">
</form>
</BODY></HTML>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
<BODY id=page>
<script type="text/javascript">
$(document).ready(function() {
$('#dodajWiersz').click(function() {
var liczba = $('#tabela tr').length;
var f1 = '<td><input type="text" class="medium" name="pozycja[]"/></td>';
var f2 = '<td><input type="text" class="medium" name="typ[]"/></td>';
var f3 = '<td><a class="delete" href="#">Usuń wiersz</a></td>';
var row = '<tr class="none" id="wiersz-'+liczba+'"><td>'+liczba+'</td>'+f1+f2+f3+'</tr>';
$('#tabela').find('tbody').append(row);
$('tr.none').removeClass('none').animate({'backgroundColor':'#66B04D','color':'#fff'},300,function(){
$(this).animate({'backgroundColor':'#fff','color':'#000'},300);
});
});
$('.delete').live('click',function() {
$(this).closest('tr').animate({'backgroundColor':'#EF3E23','color':'#fff'},300,function(){
$(this).remove();
$('#tabela > tbody > tr').each(function(i) {
$(this).find('td:first-child').text(i+1);
});
});
});
});
</SCRIPT>
<p><a href="#" id="dodajWiersz" class="add">Dodaj nowy wiersz</a></p>
<form action=index2.php method=post>
<table id="tabela">
<thead>
<tr>
<th>Lp.</th>
<th>Nazwa</th>
<th>Typ</th>
<th>Akcje</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<INPUT class=submit input type="submit" name="submit" value=" Zatwierdz ">
</form>
</BODY></HTML>
I tu mam pytanie w jaki sposób można zrobić podpowiedz wyciąganą z bazy danych dla jednego z pól.
Dziękuje za pomoc.