Append value to an input field in Javascript

Viewed 18410

Here i'm trying to append some text to an input field but everytime the old value gets replaced with new value.

HTML

<input type="text" id="taginput" class="input" name="tags">

Javascript

function update(i){
 document.getElementById('taginput').value = i.innerHTML;
  }

no jquery please.

3 Answers
<html>
<head>
</head>
<body>
<input id="my_msg" type="text">
</body>
<script>
document.getElementById('my_msg').value = "text-value";
</script>
</html>

document.getElementById('my_msg').value = "text-value";

Use above script to append 'text-value' to input field.

Thanks

Related