Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    cross browser wysiwyg

    hi all, this is the usuall "my first javascript" post.
    I'm trying to make a wysiwyg textarea..
    my example page
    very simple script.. i have two ways to go about it.
    the first two functions work but the prompt one does not, I have played with different variations but basically.. i don't know javascript.
    I usually use asp, php but its time I learn javascript.
    thanks,
    -DM

    <script type="text/JavaScript">
    <!--
    function addURL(form)
    {form.news.value= form.news.value+" <a href=\""+form.newstext.value+"\">"+form.urllink.value+"</a>";}

    function addBold(form)
    {form.news.value= form.news.value+" <b>"+form.btext.value+"</b>";}

    function boldText(bt)
    {
    var name=prompt("enter bold text");
    this.form.newstext.value=form.newstext.value+" <b>"+name+"</b>";
    }
    //-->
    </SCRIPT>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td>
    <form name="form1" method="post" action="examples/test.asp">
    link<br>
    <input name="urllink" type="text" value="" id="urllink">text<br>
    <input name="newstext" type="text" value="http://" id="newstext">url<br>
    <input name="same" type="button" class="button" id="same" onClick="addURL(this.form)" value="add it"><br>
    bold<br>
    <input name="btext" type="text" value="" id="btext">text<br>
    <input name="same" type="button" class="button" id="same" onClick="addBold(this.form)" value="add it"><br>
    <textarea name="news" rows="15" cols="45"><b>text</b></textarea><br>
    <input type="submit" name="Submit" value="Submit">
    </form>
    </td>
    <td>
    <form name="form2" method="post" action="examples/test.asp">
    <input name="bbtt" type="button" class="button" id="bbtt" onClick="boldText('bt');" value="boldText"><br />
    <textarea name="newstext" rows="15" cols="45" id="newstext"></textarea>
    </form>
    </td>
    </tr>
    </table>
    Last edited by Mapnapkin; 12-17-2004 at 08:46 PM.

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    function boldText(bt)
    {
    var name=prompt("","enter bold text");
    document.form2.newstext.value=document.form2.newstext.value+" <b>"+name+"</b>";
    }

  • #3
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks for the quick reply..
    and wow, so all i had to do was target the form name instead of just saying it was a form
    thanks so much
    ----------------------
    does anyone know how to get cursor location and insert the text at that location..
    or apply to highlited text


    -DM
    Last edited by Mapnapkin; 12-17-2004 at 07:38 PM.

  • #4
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •