Reputation: 47
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.
Upvotes: 0
Views: 3897
Reputation: 546493
Try this:
var cnEl = $('#cn');
cnEl.val(cnEl.val() + " " + $('#rand-character').text());
Upvotes: 1