We have the following code that is suppose to output html in a box below, however it is not working correctly.
When we click the button it does not generate the html, it doesnt do anything.
What we are trying to achieve is to have information input then have it output as selectable html so people can select the html and paste it on other pages.
Here is the code we are working with.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>simple html-generator example</title>
<script type="text/JScript">
var itC = "000000";
var ibC = "FFFFFF";
function sColor(iName){
var oColor, oText, iC;
switch(iName.name){
case "bC" : iC = ibC;
break;
case "tC" : iC = itC;
break;
}
oColor = document.createTextNode(DSH.ChooseColorDlg(iC).toString(16));
while (oColor.length < 6){oColor.insertData(0,0);}
oText = "#" + oColor.data.toUpperCase();
iName.value = oText;showColor();
}
function showColor(){
clr.style.background = document.gen.bC.value;
clr.style.color = document.gen.tC.value;
ibC = document.gen.bC.value;
itC = document.gen.tC.value;
}
function G(){
var f, i1, i2, i3, i4, i5, i6, sCode;
f = document.gen;
i0 = f.ttl.value;
i1 = f.bC.value;
i2 = f.tC.value;
i3 = f.tA1.value;
i4 = f.tA2.value;
i5 = f.hd1.value;
i6 = f.hd2.value;
i0.length < 1 ? i0 = "myPage" : "";
i3.length < 1 ? i3 = "(no data submitted...)" : "";
i4.length < 1 ? i4 = "(no data submitted...)" : "";
i5.length < 1 ? i5 = "#1 Data" : "";
i6.length < 1 ? i6 = "#2 Data" : "";
sCode =
"<!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN\">\r\n" +
"<html>\r\n" +
"<head>\r\n" +
"<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=ISO-8859-1\">\r\n" +
"<title>" + i0 + "<\/title>\r\n" +
"<style type=\"text\/css\">\r\n" +
"body{text-align:center;background:" + i1 + ";color:" + i2 + "\r\n}\r\n" +
"hr{color:" + i2 + "\r\n}\r\n" +
"<\/style>\r\n" +
"<\/head>\r\n" +
"<body>\r\n" +
"<h3>" + i5 + "<\/h3>\r\n" +
"<pre>" + i3 + "<\/pre>\r\n" +
"<hr>\r\n" +
"<h3>" + i6 + "<\/h3>\r\n" +
"<pre>" + i4 + "<\/pre>\r\n" +
"<\/body>\r\n" +
"<\/html>";
ifr.document.open();
ifr.document.write(sCode);
ifr.document.close();
}
function sav(){
var t = document.gen.ttl.value;
t.length < 1 ? t = "myPage" : "";
ifr.document.execCommand('saveAs', true, t)
}
</script>
<style type="text/css">
body{background:#fff
}
textarea{margin:10px
}
fieldset{text-align:center;margin:10px;padding-bottom:20px
}
table{margin-left:auto;margin-right:auto;background:buttonface
}
caption{margin-left:auto;margin-right:auto;margin-bottom:10px
}
span{padding:10px;border:2px inset
}
legend{border:3px double buttonhighlight;padding-left:10px;
padding-right:10px;margin-bottom:20px;color:buttontext;font-style:italic
}
input{vertical-align:middle;text-align:center
}
.lgnd{color:#000;background:#fff
}
div{margin:0
}
.R{text-align:right
}
iframe{margin-top:10px
}
</style>
</head>
<body>
<form action="" name="gen"
onreset="setTimeout('showColor()',200);ifr.navigate('about:blank');
this.sB.disabled=true">
<table border="1" frame="border" rules="none" cellpadding="5" cellspacing="5">
<caption>
HTML-Generator : Internet Explorer 6
</caption>
<tbody>
<tr>
<td colspan="2">
<fieldset>
<legend id="clr" class="lgnd" title="Choose Colors">Choose Colors</legend>
<span>
<input type="button" value="Background" onclick="sColor(this.form.bC)">
<input name="bC" readonly value="#FFFFFF">
</span>
<span>
<input type="button" value=" Text " onclick="sColor(this.form.tC)">
<input name="tC" readonly value="#000000">
</span>
</fieldset>
</td>
</tr>
<tr>
<td>
<fieldset>
<legend>information-blank #1</legend>
<label>Heading: </label><br>
<input name="hd1" value="#1 Data"><br>
<textarea name="tA1" rows="10" cols="30"></textarea>
</fieldset>
</td>
<td>
<fieldset>
<legend>information-blank #2</legend>
<label>Heading: </label><br>
<input name="hd2" value="#2 Data"><br>
<textarea name="tA2" rows="10" cols="30"></textarea>
</fieldset>
</td>
</tr>
<tr>
<td colspan="2">
<fieldset style="padding:10px">
<legend>HTML</legend>
<label>Title: </label>
<div>
<input type="button" name="gB" value="Generate"
onclick="G();this.form.sB.disabled=false">
<input name="ttl" value="myPage">
<input type="button" disabled value="Save As" name="sB" onclick="sav()">
</div>
<iframe id="ifr" width="100%" src="about:blank"></iframe>
</fieldset>
<div class="R">
<input type="Reset">
</div>
</td>
</tr>
</tbody>
</table>
</form>
<div><object id="DSH" classid="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b"
width="0px" height="0px"></object></div>
</body>
</html>
If someone can help us figure out the problem or point us in the direction of another script that does what we are looking for I would appreciate it. Thank you.