PDA

View Full Version : MULTIPLE LIVE PREVIEWS of form


starshine
04-16-2008, 05:18 PM
Hi,

I've got this script that shows a live real time preview of text typed in a form input area.

<script>
function preview(id1, id2){
var NewText = document.getElementById(id1).value;
splitText = NewText.split(/\n/).join("<br />");
var DivElement = document.getElementById(id2);
DivElement.innerHTML = splitText;}
</script>


BODY

There are two regions, one for the form and the other for the corresponding Preview area.

<form action="#">
<label>Address:</label>
<input type="text" id="address" onKeyUp="preview('address', 'preview-address');" />
</form>

<h1>Preview</h1>
<dl>
<dt>Address:</dt>
<dd id="preview-address"></dd>
</dl>

Well, how can I get more Preview areas? If I try copying the preview areas code twice, I still get just one preview. Can anyone get this, and show more than one multiple previews of the text typed in a form, cool...

Example:

Color: ________

So when you type in the Color form field, say

Color : Red

Then in the form Preview, what to do so that it appears twice or more like this:

Previews:

Red

Red

Red

Thanks and have a great time.

A1ien51
04-18-2008, 05:16 AM
Are you giving them different ids after you copied them?

Eric