View Single Post
  #1 (permalink)  
Old Apr 16th, 2008, 15:45
starshine starshine is offline
New Member
Join Date: Apr 2008
Location: missouri
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Smile MULTIPLE LIVE PREVIEWS of form

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 on 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.
Reply With Quote