Jquery: adding input values each time on top when click

Hi,
I am trying to write this code which the value in the input field can be added on top each time when you get the value from links,

$(document).ready(function(){	
	autofill();
});

function autofill() {
		$('.items-form a').click(function(){

			var str = "";
			str += $(this).attr('href') + " ";
			$("#inputString").val(str);

			return false;
		});
	}
<input type="text" size="30" value="" id="inputString" />

<div class="items-form">
	<a href="arts">Arts</a>
	<a href="design">Design</a>
	<a href="vectors">Vectors</a>
	<a href="games">Games</a>
	<a href="science">Science</a>	
</div>

what this code does so far is that it only change the value inside the input field each time I click on another links… what i have missed…?

any ideas will be much appreciated.

many thanks,
Lau

You mean you want to add a new value to the existing value of the input? You can retrieve the current value of the input element by doing var currentValue = $(“#inputString”).val();

Now that you have the current value, you can concatenate a new string to it. Then set value using $(“#inputString”).val(newValue)

yes that what i am trying to do. thanks for the help. will try it out.
thanks :smiley: