PDA

View Full Version : textarea class="codecontainer"?



deniseb
11-09-2006, 07:04 PM
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:


<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!

TheJoshMan
11-09-2006, 09:09 PM
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/dynamicindex11/selectform.htm

deniseb
11-09-2006, 09:58 PM
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.:)

tech_support
11-13-2006, 05:41 AM
Just a note:

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


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):



<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:



<textarea name="textarea" id="select" cols="30" rows="5" selectAll></textarea>

It'll create a link for you.