Ajax - XMLHtmlRequest with "TOGGLE" effect
<script type="text/javascript">
function script()
{
var e = document.getElementById();
if(e.innerHTML == "")
{
var oRequest;
try {
oRequest=new XMLHttpRequest();
} catch (e) {
try {
oRequest=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
oRequest=new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
alert("AJAX IS NOT SUPPORTED");
return false;
}
}
}
oRequest.onreadystatechange=function() {
if(oRequest.readyState==4)
{
document.getElementById().innerHTML = oRequest.responseText;
}
}
oRequest.open("GET","",true);
oRequest.send(null);
}
else
{e.innerHTML = "";}
}
</script>
Ajax - XMLHtmlRequest
<script type="text/javascript">
function script()
{
var e = document.getElementById("");
var oRequest;
try {
oRequest=new XMLHttpRequest();
} catch (e) {
try {
oRequest=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
oRequest=new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
alert("YOUR BROWSER DOESN'T SUPPORT AJAX!");
return false;
}
}
}
oRequest.onreadystatechange=function() {
if(oRequest.readyState==4)
{
document.getElementById("").innerHTML = oRequest.responseText;
}
}
oRequest.open("GET",,true);
oRequest.send(null);
}
</script>
Two-level navigation menu by catgories and their assigned articles
<txp:category_list parent="**SelectionInsertionPlaceholder**" exclude="**SelectionInsertionPlaceholder**" wraptag="ul" break="li" >
<txp:variable name="catclass" value="passive" />
<txp:if_category name='<txp:category />'>
<txp:variable name="catclass" value="active" />
</txp:if_category>
<txp:category title="1" link="1" class='<txp:variable name="catclass" />' />
<txp:article_custom category='<txp:category />' wraptag="ul" break="li" sort="title asc">
<txp:variable name="artclass" value="passive" />
<txp:if_article_id>
<txp:variable name="artclass" value="active" />
</txp:if_article_id>
<txp:permlink class='<txp:variable name="artclass" />'><txp:title /></txp:permlink>
</txp:article_custom>
</txp:category_list>
Added to Textpattern by Robert Wetzlmayr
PHP Doc
/**
* <<**SelectionInsertionPlaceholder**>>
*
* @copyright YourCompany
* @author YourName
* @version $Id$
**/
Added to PHP by Christopher Mioduszewski
Unify Div Heights (using jQuery)
// Make the height of all the innerDivs the same height based on the tallest one.
function unifyHeights()
{
var maxHeight = 0;
$('div#OuterContainer').children('div').each(function(){
var height = $(this).outerHeight();
//alert(height);
if ( height > maxHeight ) { maxHeight = height; }
});
$('div.innerDivs').css('height', maxHeight);
}
Added to JS by Michael D. Noga
PHP switch
switch ($op)
{
case 'op1':
//code to be executed if $op = op1;
break;
case 'op2':
//code to be executed if $op = op2;
break;
default:
//code to be executed
//if expression is different
//from both op1 and op2;
}
Added to PHP by David Reed
Drupal: watchdog
watchdog('type', 'message', null, 'WATCHDOG_NOTICE', 'link');
Added to Drupal by David Reed