SO #141158
HTML
<body>
<a href="#" class="your-class" id="valor_correto">Valor1</a>
<a href="#" class="your-class" id="valor_correto_dois">Valor2</a>
<input type="text" placeholder="Esse não é alterado.">
<input type="text" placeholder="Mas esse aqui é!" name="modify">
</body>
JavaScript
$('.your-class').click(function () {
$('input[name="modify"]').attr('value', $(this).attr('id'));
});