hi.
can someone help me in how to get the value of textbox and display on textarea?
example: i type anything in textbox then after i lost the focus on textbox
it will display on textarea..
is this possible?

thanks in advance...

Dani AI

Generated

For : pointed you in the right direction. Below are a couple of safe, practical ways to move the textbox value into a textarea and notes on which event to pick so the behavior matches what you expect.

Example — copy when the value actually changed (good for “on losing focus, if text changed” behavior):

<input id="src" type="text">
<textarea id="dst"></textarea>

<script>
document.getElementById('src').addEventListener('change', function (e) {
  document.getElementById('dst').value = e.target.value.trim();
});
</script>

Example — live copy while typing (updates immediately):

document.getElementById('src').addEventListener('input', function (e) {
  document.getElementById('dst').value = e.target.value;
});

Notes and troubleshooting:

  • Use the change event when you want an update only after the user finishes editing and leaves the field. Use input for instant feedback while typing. See the MDN docs for change and input for details (, input event).
  • value is the right property for both text inputs and textareas (HTMLInputElement.value, HTMLTextAreaElement.value).
  • If you want to append instead of replace, concatenate with a newline: dst.value += (dst.value ? '\n' : '') + val;.
  • Ensure elements have unique ids and that scripts run after the DOM is ready (or place scripts just before </body>). For very old browsers that lack addEventListener, use a feature-detection fallback.

These snippets should cover the common needs for copying a textbox value into a textarea; pick the event that matches the interaction you want.

Recommended Answers

All 2 Replies

It's possible using Javascript.
Add the onblur event to the text box and attach it to a function that replicates the textbox value in the textarea.

ok thanks this what i looking for..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.