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
    Jul 2003
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Input and Highlight Code

    Hi,

    Hopefully someone can point me to a tutorial...

    I can find tutorials on how to highlight a block of text, but what I need to do is have code inserted around a text block so that the entire thing (code and text) can be highlighted for cut and paste.

    For example, I would like someone who is not familiar with html to be able to enter a url and descriptive name, hit enter, then then appropriate codes <a href="...etc) would surround the url and link name. That person could subsequently highlight the entire block and copy and paste the resultant code into a web page builder.

    Is there a tutorial that would show how to have the code surround the user input? I've tried searching Google, this forum, and a Javascript tutorial site, but nothing appropriate comes up with my search terms (highlight javascript tutorial and similar terms).

    Any help would be very much appreciated.

    kpd

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    338
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <script type="text/javascript">
    function createLink(url,text) {
    var htmlStr =  "<a href=\"" + url + "\">" + text + "</a>";
    document.forms[0].linkCode.value = htmlStr;
    }
    </script>
    <form>
    URL: <input type="text" name="url"/><br/>
    Text: <input type="text" name="text"/>
    <input type="button" onclick="createLink(this.form.url.value,this.form.text.value);" value="Create Code"/>
    <p>
    <textarea name="linkCode"></textarea>
    </p>
    </form>
    Hope that helps!

    Happy coding!

  • #3
    New to the CF scene
    Join Date
    Jul 2003
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi nolachrymose,

    Thanks!!! It works great! I've studied the code so that I understand what is happening, but I never would have gotten that on my own...

    I appreciate your help,
    kpd

  • #4
    New to the CF scene
    Join Date
    Dec 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Where?

    Can you give me please some tutorials for creating highlighted code inside html code for example? Thancks PS. I want to be written in javascript. I have to make an editor of html
    Last edited by crisstynaa; 12-26-2007 at 03:25 PM.


  •  

    Posting Permissions

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