Im creating a script where people can submit things like tutorials. These tutorial contain examples of code and I therefore want to make that bit of code stand out from the rest when its being viewed. So what ive done is ive created a php script which take the input from a form once its submitted and then replaces certain tags which I have created with tags to make it stand out.
So basically what I need is a text box with some formatting buttons above it. If someone for example clicks on the CODE button the [code] tag will be inserted into the appropiate place in the text box. Then the next time someone clicks on that button it will then insert the closing tag which is the same but with a / before the CODE word.
Also if text is selected within the text box clicking on one of the formatting bttons will need to surround the selected text with the appropiate tags.
This works just like the posting form here on this forum.
The tags needed are:
BOLD
ITALIC
UNDERLINE
CODE
IMG
I can do the php side myself.. Al I need is the javascript which inserts the tags into the text box.
Thanks
Comments
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Developer Studio">
<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Document Title</TITLE>
<script type="text/javascript">
function afunction()
{
var mwxt = '[code]';
var fea = document.wet.frt.value;
document.wet.frt.value = mwxt + fea + " "+ mwxt;
}
</script>
<script type="text/javascript">
function jlfunction()
{
document.getElementById("frt").style.fontWeight="bold";
}
</script>
<script type="text/javascript">
function jpfunction()
{
document.getElementById("frt").style.fontStyle="italic";
}
</script>
<script type="text/javascript">
function jzfunction()
{
document.getElementById("frt").style.textDecoration="underline";
}
</script>
<script type="text/javascript">
function jwfunction()
{
var mzxt = '<img>';
var fea = document.wet.frt.value;
document.wet.frt.value = fea + mzxt + " " + mzxt;
}
</script>
</HEAD>
<BODY>
<!-- Insert HTML here -->
<form name="wet">
<input type="text" name="frt" size="30">
<input type="button" name="thisishard" onClick="afunction();">
<input type="button" name="thisishard" onClick="jlfunction();">
<input type="button" name="thisishard" onClick="jpfunction();">
<input type="button" name="thisishard" onClick="jzfunction();">
<input type="button" name="thisishard" onClick="jwfunction();">
</form>
</BODY>
</HTML>
and yes i would like it to do auto surround of selected text
The Royal Ram
...er oh wait... you are the admin ...oh dear. Silly me
sebastianastill.co.uk - My Portfolio
And yeah your right. I could get the code from this forum script but its way too complex for what I want..
The Royal Ram