
    
 $(function() { // when document has loaded  
 
   var i = $('.projectname').size() + 1; // check how many input exists on the document and add 1 for the add command to work  
   
   
   $('a#addproject').click(function() { // when you click the add link  
	   
	   var currentyear = new Date().getFullYear();
	   var r=2001;
	 
	   var option = '<select name="projectyear['+ i +']" id="projectyear['+ i +']"  ><option value="" SELECTED>Wybierz Rok</option>';

	   while (r<=currentyear) {

	   option +='<option value="'+r+'">'+r+'</option>';      
	   r++;
	   }
	   option += '</select>';
        $('<p><label>W którym roku szkoła realizowała projekt?</label> '+option+' </p><p>Nazwa projektu <input class=projectname id="projectname['+i+']" name="projectname['+i+']" type="text" class="style" ></p>').appendTo('#proj'); // append (add) a new input to the document.  
 // if you have the input inside a form, change body to form in the appendTo  
        i++; //after the click i will be i = 3 if you click again i will be i = 4  
     });  
  
    $('a#remove').click(function() { // similar to the previous, when you click remove link  
   if(i > 1) { // if you have at least 1 input on the form  
        $('input:last').remove(); //remove the last input  
         i--; //deduct 1 from i so if i = 3, after i--, i will be i = 2  
    }  
     });  
   
 });  
  
