I'm creating a text to bash script generator and I'm having trouble trying to enter BASH tags into a textarea.
Here's my code form the HTML page:
Code: Select all
<html>
<head>
<title>BASHBuilder</title>
</head>
<script type="text/javascript">
<!--
function formatText(el,tagstart,tagend) {
if (el.setSelectionRange) {
el.value = el.value.substring(0,el.selectionStart) + tagstart + el.value.substring(el.selectionStart,el.selectionEnd) + tagend + el.value.substring(el.selectionEnd,el.value.length)
}
else {
// IE code here...
}
}
function preview() { msg=open("","DisplayWindow","scrollbars=1,resizable=yes,toolbar=1,directories=no,menubar=yes,width=800,height=600,left=240,top=80");
msg.document.write('<pre>',form1.text1.value,'</pre>');
}
//-->
</script>
<body onload="document.form1.text1.focus();">
<center>
<form name="form1">
<textarea id="text1" rows="12" cols="60" wrap="virtual"></textarea>
<br/><input type="button" value="Convert!" onclick="document.form1.text1.select();formatText(document.getElementById('text1'),'echo "','"');"/> <input type="reset" value="Clear" onclick="document.form1.text1.focus()" /> <INPUT TYPE="button" VALUE="Preview" onClick="preview(this)" class=button>
</center>
</body>
</html>
I'd be willing to resort to writing it in PHP if necessary especially if it would be easier.
Any help is appreciated...