body.innerHTML til Acces felt
HejDette spørgsmål er fra tidligere indlæg i Dhtml kategorien http://www.eksperten.dk/spm/205153
Det jeg efterlyser er en gem knap som der skal sende til et acces felt, og at der i Iframen bliver hivet html ud af et Acces felt.
Se eksempel http://peterelkjaer.dk/x/bold.htm
Her er slutningen af scriptet
var theHtml = "" + document.frames("myEditor").document.frames("textEdit").document.body.innerHTML + "";
document.all.EditorValue.value = theHtml;
}
function OnFormSubmit(){
if(confirm("Nu gemmes dokumentet!")){
copyValue();
document.fHtmlEditor.submit();
}
}
</script>
Her er hele scriptet:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<style type="text/css">
<!--
.clsCursor { cursor: hand}
-->
</style>
<form name="fHtmlEditor" method="POST" action="">
<textarea name="EditorValue" style="display: none;"></textarea>
<script language="JavaScript">
function initToolBar(ed) {
var eb = document.all.editbar;
if (ed!=null) {
eb._editor = window.frames['myEditor'];
}
}
function doFormat(what) {
var eb = document.all.editbar;
if(what == "FontName"){
if(arguments[1] != 1){
eb._editor.execCommand(what, arguments[1]);
document.all.font.selectedIndex = 0;
}
} else if(what == "FontSize"){
if(arguments[1] != 1){
eb._editor.execCommand(what, arguments[1]);
document.all.size.selectedIndex = 0;
}
} else {
eb._editor.execCommand(what, arguments[1]);
}
}
function copyValue() {
var theHtml = "" + document.frames("myEditor").document.frames("textEdit").document.body.innerHTML + "";
document.all.EditorValue.value = theHtml;
}
function OnFormSubmit(){
if(confirm("Nu gemmes dokumentet!")){
copyValue();
document.fHtmlEditor.submit();
}
}
</script>
<table border="1" cellspacing="0" cellpadding="0" bgcolor="#CCCCCC" width="40%" height="40%" bordercolor="#CCCCCC">
<tr valign="top">
<td>
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
<tr valign="top">
<td valign="top">
<div id=editbar >
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="left">
<tr>
<td height="41">
<table border="0">
<tr>
<td nowrap valign="baseline">
<div align="left">
<select name="font" onChange=" doFormat('FontName',document.all.font.value);" style="font: 8pt verdana;">
<option value="1" selected >Select Font...</option>
<option value="arial">Arial, Helvetica, sans-serif</option>
<option value="times" >Times New Roman, Times, serif</option>
<option value="courier">Courier New, Courier, mono</option>
<option value="georgia">Georgia, Times New Roman</option>
<option value="verdana">Verdana, Arial, Helvetica</option>
</select>
<select name="size" onChange="doFormat('FontSize',document.all.size.value);" style="font: 8pt verdana;">
<option value="None" selected>Size</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="+1">+1</option>
<option value="+2">+2</option>
<option value="+3">+3</option>
<option value="+4">+4</option>
<option value="+5">+5</option>
<option value="+6">+6</option>
<option value="+7">+7</option>
</select>
<img class='clsCursor' src="editor_images/Bold.gif" width="16" height="16" border="0" align="absmiddle" alt="Bold text" onClick="doFormat('Bold')"> 
<img class='clsCursor' src="editor_images/Italics.gif" width="16" height="16" border="0" align="absmiddle" alt="Italic text" onClick="doFormat('Italic')"> 
<img class='clsCursor' src="editor_images/underline.gif" width="16" height="16" border="0" align="absmiddle" alt="Underline text" onClick="doFormat('Underline')" > 
<img class='clsCursor' src="editor_images/left.gif" width="16" height="16" border="0" alt="Align Left" align="absmiddle" onClick="doFormat('JustifyLeft')">
<img class='clsCursor' src="editor_images/centre.gif" width="16" height="16" border="0" alt="Align Center" align="absmiddle" onClick="doFormat('JustifyCenter')"> 
<img class='clsCursor' src="editor_images/right.gif" width="16" height="16" border="0" alt="Align Right" align="absmiddle" onClick="doFormat('JustifyRight')"> </div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr valign="top" align="left">
<td valign="top">
<table width="100%" border="0" height="100">
<tr valign="top">
<td width="100%" height="100%">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
<tr valign="top">
<td bgcolor="#FFFFFF"><iframe id=myEditor src="pd_edit.htm" onFocus="initToolBar(this)" width=100% height=100%></iframe></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
