views:

35

answers:

2

I want to have users be able to enter data into a text box and instantly have that text appear in another div as content with a character limit on the input box.

Much like how SO does it when asking a question but for a different application.

I am using the YUI3 framework if that makes any difference.

Unfortunately I don't know where to start so any help is appreciated.

Thanks!

+1  A: 

Something like this should work:

<input type="text" id="text1" onchange="document.getElementById('div1').innerHTML=document.getElementById('text1').value">

<div id="div1">
</div>

But I would place a function in the onChange event instead of writing the code in the tag.

Todd Moses
Wow I figured it would be simple but was not expecting that :)
After testing I noticed that it only works once you click out of the box. The others that I have seen change the other div while your typing.
A: 

Needed to use 'onkeyup' and it worked properly.

<input type="text" id="text1" onkeyup="document.getElementById('div1').innerHTML=document.getElementById('text1').value">

<div id="div1">

</div>

Thanks.