views:

683

answers:

1

Hey guys, here is my html output:

<script language="javascript">
  function append_suggestion() {
    $('input[name="cn"]').append($('#rand-character').val());
  }
</script>

<form name="form" action="/search/results" method="get" class="search-form" id="search-autocomplete">
  <input size="28" class="search-field" id="cn" name="cn" type="text" value="" />      <input type="submit" name="" value="" class="button" />
</form>

<a href="#" id="rand-character" onclick="append_suggestion()">link</a>

After clicking the link nothing happens (it's supposed to insert link text into the input field). How to correct this link behavior?

Thank you.

+1  A: 

Try this:

var cnEl = $('#cn');
cnEl.val(cnEl.val() + " " + $('#rand-character').text());
nickf
That's it! Thank you very much! :)
Den Thomas