Copy Div content to Clipboard

<div id="myDiv">This is the content to get copied to the text area and then to clipboard</div>

<script type="text/javascript">
function copy2cb()
{
// If it's FireFox, then sets the

// "signed.applets.codebase_principal_support" to TRUE
if (navigator.userAgent.indexOf("Firefox")!=-1)
user_pref("signed.applets.codebase_principal_support", true);

var ta= document.getElementById ("myhidta");
var d= document.getElementById ("code_collective");
// Transfer the text from the DIV to the hidden textarea
ta.innerText= d.innerText;
// create the text range
var t= ta.createTextRange ();
// do this if you wanna remove the format of the text within
t.execCommand('RemoveFormat');
// Then execute the copy command
t.execCommand('Copy');
}
</script>

<textarea style="display:none;" id="myhidta"></textarea>
<input type="button" value="Copy" onClick="copy2cb();"/>

Copy to Clipboard Button

<script type="text/javascript">

function CopyToClipboard()

{
CopiedTxt = document.selection.createRange();
CopiedTxt.execCommand("Copy");
}

</script>

<form name="Form1">
Here is some text you can copy. You can copy text from anywhere on the page, simply select it and press the Copy to clipboard button. Then you can paste it anywhere you want, in Notepad, Visual Studio or in the textarea below. <br />
<br />
<textarea id="txtArea" cols="60" rows="5">You can also copy text from this textarea. Or you can paste the text here, using the Ctrl+V key combination.</textarea>
<br />
<input type="button" onClick="CopyToClipboard()" value="Copy to clipboard" />
</form>

Search Box - with clear

<div id="main_search">
<form method="get" id="search_form" action="<?php bloginfo('url'); ?>/" >

<input type="text" class="search_field" value="Search Keywords" name="s" id="s" onfocus="if (this.value == 'Search Keywords') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search Keywords';}" />

<input type="submit" id="submit_button" name="submit" value="Submit" />

<!-- Replace the submit input above with this for a custom image --

<input type="image" id="submit_button" src="/graphics/search_btn.png" name="submit" value="Submit" />

-->

</form>
</div>

 

<!-- Here is an inline technique to handle the clear -->

<input type="text" name="search_query" id="search_query" value="SEARCH" onfocus="if (this.value == 'SEARCH') {this.value = '';}" onblur="if (this.value == '') {this.value = 'SEARCH';}"/>