Hi there,
I have an 'editable' DIV tag where I can copy/paste e.g. a word file, where the layout is kept [bold/italic/tables/...]
The div contains a submit button. This will show the HTML code in a textarea.
All that works fine, the only little problem I encounter is that I cannot pass the information in a form!
I always get an error that the field oTextarea is not defined!?
Anyone any suggestions? You can simply copy/paste the code below.
Tnx in advance!
Bram
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Editable Regions Sample</TITLE>
<STYLE>
body{
margin:0;
background:white;
font-family:verdana;
font-size:80%;
}
.bar{
background:#336699;
width:100%;
height:30px;
border-top:1px solid #99CCFF;
border-bottom:1px solid #000000;
}
.desbar{
background:#FFFFFF;
width:100%;
padding: 10px;
border-top:1px solid #CCCCCC;
border-bottom:1px solid #000000;
color:black;
font-size:8pt;
height:105;
}
.title{
font-size:15pt;
color:white;
padding-left:10px;
}
PRE { margin:0}
a:link
{
text-decoration:none;
color:white
}
a:visited
{
text-decoration:none;
color:white
}
a:active
{
text-decoration:none;
color:white
}
a:hover
{
text-decoration:none;
color:yellow
}
BUTTON {cursor:hand; background:#ffffff; border-color:#99ccff; font-weight:bold;}
</STYLE>
<SCRIPT>
function fnToggleEdits(oObj,oBtn) {
currentState = oObj.isContentEditable;
newState = !currentState;
oObj.contentEditable = newState;
newState==false ? oBtn.innerHTML='Editing On' :
oBtn.innerHTML='Editing Off';
}
</SCRIPT>
</HEAD>
<BODY >
<!-- TOOLBAR_START --><!-- TOOLBAR_EXEMPT --><!-- TOOLBAR_END -->
<div align="center">
<DIV UNSELECTABLE ALIGN="center" STYLE="height:210; width:90%; background-color:#99CCFF; border:1px solid black">
<DIV CLASS="bar title">HTMLEditor (Content Editable DIV)</DIV>
<DIV style="padding:10px">
<BUTTON UNSELECTABLE TITLE="Bold" onclick='document.execCommand("Bold" oDiv.focus();' >Bold</BUTTON>
<BUTTON UNSELECTABLE TITLE="Italic" onclick='document.execCommand("Italic" oDiv.focus();' ><I>Italic</I></BUTTON>
<BUTTON UNSELECTABLE TITLE="Underline" onclick='if (oDiv.isContentEditable==true) document.execCommand("Underline" oDiv.focus();'><U>Underline</U> </BUTTON>
<button unselectable="On" onclick='document.execCommand("InsertOrderedList"oDiv.focus();'
title="Ordered List"> <B>OL</B></button>
<button unselectable="On" onclick='document.execCommand("InsertUnorderedList"oDiv.focus();'
title="Unordered List"> <B>UL</B></button>
<button unselectable="On" onclick='document.execCommand("Paste"oDiv.focus();'
title="Paste content from clipboard"> <B>Paste from clipboard!</B></button>
</DIV>
<DIV id=oDiv contenteditable ALIGN=left STYLE="height:100; width:95%;background-color:white; font-face:Arial; padding:3;
border:inset #99ccff; scrollbar-base-color:#99ccff; overflow=auto;"></DIV>
<!--- <BUTTON UNSELECTABLE TITLE="Append from HTMLEditor" onclick='oTextarea.value+=oDiv.innerHTML;oTextarea.focus();'>Append to TextEditor</BUTTON> --->
<BUTTON UNSELECTABLE TITLE="Append from HTMLEditor" onclick='oTextarea.value+=oDiv.innerHTML;'>Append to TextEditor</BUTTON>
</DIV>
</div>
<BR/>
<div align="center">
<DIV UNSELECTABLE ALIGN="center" STYLE="height:210; width:90%; background-color:#99ccff; border:1px solid black">
<DIV CLASS="bar title">TEXTEditor (TEXTAREA)</DIV>
<FORM ACTION="showcontent.cfm" METHOD="POST">
<TEXTAREA name="oTextarea" id="oTextarea" STYLE="height:100; width:95%;background-color:white; padding:3; overflow=auto;"></TEXTAREA>
<BR/>
<!--- <BUTTON UNSELECTABLE TITLE="Append to HTMLEditor" onclick='oDiv.innerHTML+=oTextarea.value;oTextarea.focus();'> Submit</BUTTON> --->
</DIV>
</div>
<INPUT TYPE="submit" VALUE="OK">
</FORM>
</body>
</html>
I have an 'editable' DIV tag where I can copy/paste e.g. a word file, where the layout is kept [bold/italic/tables/...]
The div contains a submit button. This will show the HTML code in a textarea.
All that works fine, the only little problem I encounter is that I cannot pass the information in a form!
I always get an error that the field oTextarea is not defined!?
Anyone any suggestions? You can simply copy/paste the code below.
Tnx in advance!
Bram
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Editable Regions Sample</TITLE>
<STYLE>
body{
margin:0;
background:white;
font-family:verdana;
font-size:80%;
}
.bar{
background:#336699;
width:100%;
height:30px;
border-top:1px solid #99CCFF;
border-bottom:1px solid #000000;
}
.desbar{
background:#FFFFFF;
width:100%;
padding: 10px;
border-top:1px solid #CCCCCC;
border-bottom:1px solid #000000;
color:black;
font-size:8pt;
height:105;
}
.title{
font-size:15pt;
color:white;
padding-left:10px;
}
PRE { margin:0}
a:link
{
text-decoration:none;
color:white
}
a:visited
{
text-decoration:none;
color:white
}
a:active
{
text-decoration:none;
color:white
}
a:hover
{
text-decoration:none;
color:yellow
}
BUTTON {cursor:hand; background:#ffffff; border-color:#99ccff; font-weight:bold;}
</STYLE>
<SCRIPT>
function fnToggleEdits(oObj,oBtn) {
currentState = oObj.isContentEditable;
newState = !currentState;
oObj.contentEditable = newState;
newState==false ? oBtn.innerHTML='Editing On' :
oBtn.innerHTML='Editing Off';
}
</SCRIPT>
</HEAD>
<BODY >
<!-- TOOLBAR_START --><!-- TOOLBAR_EXEMPT --><!-- TOOLBAR_END -->
<div align="center">
<DIV UNSELECTABLE ALIGN="center" STYLE="height:210; width:90%; background-color:#99CCFF; border:1px solid black">
<DIV CLASS="bar title">HTMLEditor (Content Editable DIV)</DIV>
<DIV style="padding:10px">
<BUTTON UNSELECTABLE TITLE="Bold" onclick='document.execCommand("Bold" oDiv.focus();' >Bold</BUTTON>
<BUTTON UNSELECTABLE TITLE="Italic" onclick='document.execCommand("Italic" oDiv.focus();' ><I>Italic</I></BUTTON>
<BUTTON UNSELECTABLE TITLE="Underline" onclick='if (oDiv.isContentEditable==true) document.execCommand("Underline" oDiv.focus();'><U>Underline</U> </BUTTON>
<button unselectable="On" onclick='document.execCommand("InsertOrderedList"oDiv.focus();'
title="Ordered List"> <B>OL</B></button>
<button unselectable="On" onclick='document.execCommand("InsertUnorderedList"oDiv.focus();'
title="Unordered List"> <B>UL</B></button>
<button unselectable="On" onclick='document.execCommand("Paste"oDiv.focus();'
title="Paste content from clipboard"> <B>Paste from clipboard!</B></button>
</DIV>
<DIV id=oDiv contenteditable ALIGN=left STYLE="height:100; width:95%;background-color:white; font-face:Arial; padding:3;
border:inset #99ccff; scrollbar-base-color:#99ccff; overflow=auto;"></DIV>
<!--- <BUTTON UNSELECTABLE TITLE="Append from HTMLEditor" onclick='oTextarea.value+=oDiv.innerHTML;oTextarea.focus();'>Append to TextEditor</BUTTON> --->
<BUTTON UNSELECTABLE TITLE="Append from HTMLEditor" onclick='oTextarea.value+=oDiv.innerHTML;'>Append to TextEditor</BUTTON>
</DIV>
</div>
<BR/>
<div align="center">
<DIV UNSELECTABLE ALIGN="center" STYLE="height:210; width:90%; background-color:#99ccff; border:1px solid black">
<DIV CLASS="bar title">TEXTEditor (TEXTAREA)</DIV>
<FORM ACTION="showcontent.cfm" METHOD="POST">
<TEXTAREA name="oTextarea" id="oTextarea" STYLE="height:100; width:95%;background-color:white; padding:3; overflow=auto;"></TEXTAREA>
<BR/>
<!--- <BUTTON UNSELECTABLE TITLE="Append to HTMLEditor" onclick='oDiv.innerHTML+=oTextarea.value;oTextarea.focus();'> Submit</BUTTON> --->
</DIV>
</div>
<INPUT TYPE="submit" VALUE="OK">
</FORM>
</body>
</html>