Jquery change prev() input field
<p>Ok so i am trying to change the value of an input field by using jquery's prev() function.  I have a text field with some links after it.  When someone clicks on the link i want it to change the previous </p>

<pre><code>&lt;label&gt;
    &lt;input type="text"/&gt;
&lt;/label&gt;

&lt;ul&gt;
  &lt;li onclick="field('name1','value1');"&gt;&lt;a href="#"&gt;link1&lt;/a&gt;&lt;/li&gt;
  &lt;li onclick="field('name2','value2');"&gt;&lt;a href="#"&gt;link2&lt;/a&gt;&lt;/li&gt;  
&lt;/ul&gt;

&lt;script type="text/javascript"&gt;
     function field($name,$value){
     $(this).prev("input").attr('name','$name');
     $(this).prev("input").attr('value','$value');
}
&lt;/script&gt;
</code></pre>

<p>i think you can see what i am trying to do.  I want them person to click a link and it change the value and name attributes of the text field and obviously display the new value inside the the text box.  I want to use "this" so that i can use this anywhere instead of specifying a id or class.  I think im close but haven't gotten it to work yet.  Am i using the correct jquery script or should i be using something different?  Thanks.</p>
