Multiple lines in table reusing same jquery code

Hi Gurus

I need a bit of help on a jquery submission

I ahve a php script which iterates through a db call. This produces a table of information like

Name - Age - etc and a button saying add to list.

When the button is clicked the relevant line is added to the list interactively via jquery using the placement.php page in the code below. Here is the code I use


$(document).ready(function() {

		
		$("#find_host").click(function(){
		
		var postcode = $('#place_postcode').val();
		var max_distance = $('#max_distance').val();
		var dataString = "postcode="+postcode+"&max_distance="+max_distance;
		if(postcode.length>0){
		  $.ajax({
			type: "GET",
			url: "includes/placement.php",
			data: dataString,
			success: function(server_response){
			  $('#txtResult').html(server_response).show();
			}
		  });
		}return false;
		});


Is fine for a single row in a table where there is only one #name and 1 #age but I want to reuse the code for every iteration of the line in the table.

for instance
Name-1 - Age-1 - etc and a button saying add to list. button_1
Name-2 - Age-2 - etc and a button saying add to list. button_2
Name-3 - Age-3 - etc and a button saying add to list. button_3
Name-4 - Age-4 - etc and a button saying add to list. button_4

So the jquery needs to be told which button to listen for i.e #find_host1 or #find_host2 I cant think of a way of doing this without also iterating the jquery for each button


$(document).ready(function() {

		
		$("#find_host1").click(function(){
		
etc etc

$(document).ready(function() {

		
		$("#find_host2").click(function(){
		
etc etc


Any help would be great.

Thanks in advance

Keith

Try using the Attribute Starts With Selector