Click to See Complete Forum and Search --> : Code Generator Problems


elwell
08-09-2003, 04:51 PM
I have this code generator and i would like to be able to use tags like script and html and stuff but i cant just put the in " " . Does anyone know a way to write tags like those and have them appear as text.


<html><head><title>Javascript and Html Code Generators</title>
<script type="text/javascript">
function makealert() {
document.getElementById('alertoutput').value = "alert('" +document.getElementById('alertinput').value +"')";
}
</script>
</head>

<body>
Alert Generator. What do you want it to say?<br />
<input type="textbox" name="alertinput" id="alertinput" />
<input type="button" onClick="makealert()" value="Generate" />
<br />
Code:<br /><textarea name="alertoutput" id="alertoutput" rows="5" cols="30">CODE</textarea>

</body>
</html>

David Harrison
08-09-2003, 05:07 PM
To make a " appear you can put this \", so that this:

alert("Lavalamp said, \"Hi.\"");

will alert this:

Lavalamp said, "Hi."

elwell
08-09-2003, 05:13 PM
I want to be able to have <script> and <html> tags in the outcome not just "

David Harrison
08-09-2003, 05:18 PM
Well for the < you can put &amplt; and for > you can put &ampgt;

lt and gt stand for less than and greater than.

Try this:

document.write("&amplt;html&ampgt;");

elwell
08-09-2003, 05:20 PM
okay. thank you.;)

David Harrison
08-09-2003, 05:22 PM
Happy to help. :)