Author Archives: invtr

Javascript to show/hide many divs

Javascript code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<script language="javascript">
<!--
 
var state = 'none';
 
function showhide(layer_ref) {
 
if (state == 'block') {
state = 'none';
}
else {
state = 'block';
}
if (document.all) { //IS IE 4 or 5 (or 6 beta)
eval( "document.all." + layer_ref + ".style.display = state");
}
if (document.layers) { //IS NETSCAPE 4 or below
document.layers[layer_ref].display = state;
}
if (document.getElementById &&!document.all) {
hza = document.getElementById(layer_ref);
hza.style.display = state;
}
}
//--<
</script>;

HTML code

1
2
<p><a href="#" onclick="showhide('div1');">show/hide me</a></p>
<div id="div1" style="display: none;">This is the content</div>

Rapid application development – which framework to use?

I always want to do a very fast application development. This can only be done with what we call a “framework”. I have been doing a lot of research on popular PHP framework but not yet decided which one to use.

Some of them are cakephp, codeigniter, symphony and rapyd.

After using it for some time will plan to come out with own framework for better control and easy modification on the code.

Inserting source code in a blog post

I’ve been looking for WP plugin to add source code in blog posting. I want to share my code sample via the blog. At last I found this WP-Syntax plugin.

Here how a source code will look like

1
2
3
<?php
  echo "Hello World!";
?>

You need to add <pre lang=”php” line=”1″> tag before and </pre> tag after the source code. The parameter line=1 is to show the line number

PHP script to get domain from URL string

Sometimes maybe you need to get a domain name from a URL string. Here is the code

1
2
3
4
5
6
7
8
9
10
11
12
function GetDomain($url)
{
$nowww = ereg_replace(’www.,,$url);
$domain = parse_url($nowww);
if(!empty($domain["host"]))
    {
     return $domain["host"];
     } else
     {
     return $domain["path"];
     }
}

source