Results 1 to 4 of 4

Thread: textarea class="codecontainer"?

  1. #1
    Join Date
    Nov 2006
    Location
    CA
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default textarea class="codecontainer"?

    I need to create a webpage like Dynamic Forums that has code inside a textarea where the visitor clicks to highlight text and copy to clipboard.
    I looked at the source code for dyanmic forums webpage and the code says:

    Code:
    <form>
    <div align="left">
    <a class="selectall" href="#" onclick="highlight(0); return false">Select All</a><br>
    <textarea class="codecontainer" rows="8" name="S1" cols="45" wrap="virtual">
    I am not familiar with CSS and assume the class="codecontainer" is located on a CSS page???

    Does anyone know how I can do this?
    Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Ft. Smith, AR
    Posts
    795
    Thanks
    57
    Thanked 129 Times in 116 Posts

    Wink

    Hey, I think what you're looking for can be found here on DynamicDrive... It's not CSS... It's actually javascript. They more than likely have just specified a class for the textareas for visual purposes... but nonetheless here is the link to what you are looking for...

    http://www.dynamicdrive.com/dynamici...selectform.htm

  3. #3
    Join Date
    Nov 2006
    Location
    CA
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    that is almost exactly what I was looking for! Thanks so much, I'm halfway there. The other half is that it is code that I am putting inside the textarea, so I think I need to do something special for it? like class="codecontainer" - but I don't know what this does? Maybe I don't need it?
    Thanks for your reply.

  4. #4
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Just a note:

    Copy to Clipboard
    - Won't work on FF, only in IE. And it will prompt you in IE7.

    Quote Originally Posted by deniseb
    so I think I need to do something special for it? like class="codecontainer" - but I don't know what this does?
    That's a class. To apply the special highlighting and fancy fonts.

    Here's my version to the code (without copy and paste):

    Code:
    <script type="text/javascript">
    function selectAll(id)	{
    
    	document.getElementById(id).focus();
    	document.getElementById(id).select();
    }
    function createLink(id)	{
    var t=document.createTextNode('Select All');
    var a=document.createElement('a');
    a.setAttribute("href", "javascript:selectAll('"+id+"')", 0);
    a.appendChild(t);
    document.body.appendChild(a);
    }
    
    function findSelectBoxes()	{
    	var se = document.getElementsByTagName("textarea")
    	for (i=0;i < se.length;i++)	{
    		var selectAll = se[i].getAttribute("selectAll")
    		if (selectAll=="")	{
    			createLink(se[i].id)
    		}
    	}
    }
    setTimeout("findSelectBoxes()",100)
    </script>
    In your textarea, you'll need to specify an ID and put "selectAll" at the end.

    Example:

    Code:
    <textarea name="textarea" id="select" cols="30" rows="5" selectAll></textarea>
    It'll create a link for you.
    Last edited by tech_support; 11-13-2006 at 05:47 AM.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

Bookmarks

Posting Permissions

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