Forum Moderators: open

Message Too Old, No Replies

Entered Text displays immediately Elsewhere

         

Capital_C

8:52 pm on Nov 9, 2008 (gmt 0)

10+ Year Member



Don't know if that was a good title or not.

I'm building a form that just takes in text. As users insert text into the text-boxes, I'd like to immediately show them their text in html.

What I'm doing is like in Google Adwords when you type your advertisement, every letter you type immediately shows up in a preview of your advertisement right next to it.

How would I do this? I can't find any scripts to point me in the right direction.

thanks!

astupidname

10:40 pm on Nov 9, 2008 (gmt 0)

10+ Year Member



Place the following script in the head section:

<script type="text/javascript">
function copyWords(obj){
document.getElementById("copiedText").value = obj.value; /*** copies input value to another form input ***/
document.getElementById("two").innerHTML = obj.value; /*** copies input value to a non-input html element using innerHTML ***/
}
</script>

<form action="">
<p><input type="text" size="50" onkeyup="copyWords(this);" />
<input id="copiedText" type="text" size="50" readonly="readonly" /></p>
</form>

<p id="two"></p>

Capital_C

3:55 am on Nov 10, 2008 (gmt 0)

10+ Year Member



Hey astupidname, love the name!

Thanks, I just did a lot of study about events. Haven't done much with them in a long time--I'm usually programming connections to DB's.

Your suggestion is great, for what I need, I'm using the innerHTML portion.

thanks again!

astupidname

7:24 am on Nov 10, 2008 (gmt 0)

10+ Year Member



Thanks, and you're welcome!