Text box inserts

PythonPython Forum LeaderThe Royal RAM
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

The Royal Ram

Comments

  • kinkkink serious member VPS - Virtual Prince of the Server
    you can add another function that fires at the end if you want the tags to be auto surrounding let me know + you got to add vaklues to the buttons


    <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>
  • PythonPython Forum Leader The Royal RAM
    well that has confused the crap out of me....

    and yes i would like it to do auto surround of selected text

    The Royal Ram

  • kinkkink serious member VPS - Virtual Prince of the Server
    get that program to work. i have a prototype that writes out everything in a html page and it works but getting the text to perform properly in a textarea is beyond me
  • strangedarstrangedar Senior Member The Royal RAM
    you could always nick some script from this forum.. I'm sure the admin could find the bit you want and e-mail it to you if you havent got aa forum.. Or if you do have a forum just look for the code...

    ...er oh wait... you are the admin ...oh dear. Silly me :o
    strangedarknesssig.jpg
    sebastianastill.co.uk - My Portfolio
  • PythonPython Forum Leader The Royal RAM
    I am the admin of this forum :)

    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

Sign In or Register to comment.