linking a textfield with buttons in a div

linking a textfield with buttons in a div

hi all,
i have created a form which is like this.

<form name="form" action="servlet" method="get" >
password <input type=text /> <a href="" id=measurement > advs setting </a>  <br>
<input type=submit value=submit />
</form>


<div id=SetLoc >
<table>
    <tr>
          <td>
                <input class="keys" type=button value=M />
          </td>
                <td> <input class="keys" type=button value=D />
          </td>
                <td> <input class="keys" type=button value=F />
          </td>
                <td> <input class="keys" type=button value=L />
          </td>
   </tr>
 </table>
</div>

now, i have a div SetLoc which has some advanced settings for measurements. now what i want is when the user clicks on any of the buttons, the value should be added to the previous textfield.

here the important thing is that i cant use the ID or name of the textfield as i will be using the same div at many places and i need to put the values from these button to the textfield just before this div.

i am calling this div like this

$(this).next( $("#SetLoc").slideToggle() );

so it will be showing the div just below this.  now how to put the button values in the textfield above it??