Okay well I was fiddling with this
HTML Code:
<!DOCTYPE html>
<html>
<head>
<?php include 'settings.php'; ?>
<title>
Html Editor
</title>
<style type="text/css">
#window1 {
margin: 0;
background-color:<?php echo $fldrwindow1color; ?>;
word-wrap: break-word;
}
#window2 {
margin: 0;
background-color:<?php echo $fldrwindow2color; ?>;
word-wrap: break-word;
}
html, body {
height: 100%;
}
body {
background-color:<?php echo $fldrbgcolor; ?>;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript">
function clearwindow(){
var window1contents = document.getElementById('window1').innerHTML;
var window2contents = document.getElementById('window2').innerHTML;
if(window1contents == "<i>Click Here to Start Editing</i>"){
document.getElementById('window1').innerHTML = "<html><br /><head><br /></head><br /><body><br /></body><br /></html>";
document.getElementById('window2').innerHTML = "";
}
}
function resetwindow() {
var window1contents = document.getElementById('window1').innerHTML;
var window2contents = document.getElementById('window2').innerHTML;
document.getElementById('window1').innerHTML = "<i>Click Here to Start Editing</i>";
document.getElementById('window2').innerHTML = "<I>Viewing Window</I>";
}
</script>
<script type="text/javascript">
jQuery(function($){
var field1 = $('#window1');
var update = $('#update');
update.click(function(){
if(!field1.html()){
alert("Please enter a value");
field1.focus();
return;
}
jQuery.ajax({
url: 'postedit.php',
type: 'post',
data: 'field1value=' + encodeURIComponent(field1.html()),
success: function(results){
//alert(results);
if(fillwindow.filled){return;}
$('#window2').html(results);
}
});
});
});
</script>
</head>
<body onload="this.focus()">
<div style="float:left; width:7.5%; height:80%;"></div>
<div style="float:left; width:33.3%; height:80%; border:3px darkgrey solid; overflow:auto;" id="window1" onfocus="clearwindow()" contenteditable><i>Click Here to Start Editing</i></div>
<div style="float:left; width:2%; height:80%;"></div>
<div style="float:left; width:33.3%; height:80%; border:3px darkgrey solid; overflow:auto;" id="window2"><i>Viewing Window</i></div>
<br style="clear: left;">
<div style="float:left; width:7.5%; height:10%;"></div>
<input type="button" value="Update" id="update" style="margin-left:0;">
<input type="button" value="Reset" onclick="resetwindow()">
</body>
</html>
settings.php
PHP Code:
<?php
$fldrbgcolor = "Grey";
$fldrwindow1color = "White";
$fldrwindow2color = "White";
?>
I haven't changed postedit.php
I must have stuffed something up because now when you use the enter key in
#window1, it stuff up the window by adding a double break and moving all the #window1 text down a line. Any help???
Bookmarks