Kamis, 05 Agustus 2010

Mig33

Meet friends, chat and have fun!


Our community has created the world's
best place for chat. You can meet new friends, connect with popular IMs, play games and much more ...
Click Mig33 to join us.
Read More - Mig33

Rabu, 23 Juni 2010

Drop down Menu and Drop down Search Box


File: dropdown.js

// ***** Popup Control *********************************************************

// ***** at_show_aux *****

function at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );
  var top  = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0;
  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }
  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}
// ***** at_show *****
function at_show()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);
  at_show_aux(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}
// ***** at_hide *****
function at_hide()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);
  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 333);
}
// ***** at_click *****
function at_click()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);
  if (c.style.visibility != "visible") at_show_aux(p.id, c.id); else c.style.visibility = "hidden";
  return false;
}
// ***** at_attach *****
// PARAMETERS:
// parent   - id of the parent html element
// child    - id of the child  html element that should be droped down
// showtype - "click" = drop down child html element on mouse click
//            "hover" = drop down child html element on mouse over
// position - "x" = display the child html element to the right
//            "y" = display the child html element below
// cursor   - omit to use default cursor or specify CSS cursor name
function at_attach(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);
  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;
  c.style.position   = "absolute";
  c.style.visibility = "hidden";
  if (cursor != undefined) p.style.cursor = cursor;
  switch (showtype)
  {
    case "click":
      p.onclick     = at_click;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
    case "hover":
      p.onmouseover = at_show;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
  }
}

File: sample.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Dropdown Sample</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords"    content="" />
<script type="text/javascript" src="dropdown.js"></script>
<style type="text/css">
body { font-size: 0.7em; }
h3   { font-size: 1.6em; margin: 0px; }
a.sample_attach, a.sample_attach:visited, div.sample_attach
{
  display: block;
  width:   100px;
  border:  1px solid black;
  padding: 2px 5px;
  background: #FFFFEE;
  text-decoration: none;
  font-family: Verdana, Sans-Sherif;
  font-weight: 900;
  font-size: 1.0em;
  color:   #008000;
}
a.sample_attach, a.sample_attach:visited { border-bottom: none; }
div#sample_attach_menu_child             { border-bottom: 1px solid black; }
form.sample_attach
{
  position: absolute;
  visibility: hidden;
  border:  1px solid black;
  padding: 0px 5px 2px 5px;
  background: #FFFFEE;
}
form.sample_attach b
{
  font-family: Verdana, Sans-Sherif;
  font-weight: 900;
  font-size: 1.1em;
}
input.sample_attach { margin: 1px 0px; width: 170px; }
</style>
</head>
<body>
<div>
<h3>Dropdown Sample</h3>
<!-- ***** Dropdown Menu *************************************************** -->
<br /><br />
<div id="sample_attach_menu_parent" class="sample_attach">Main Menu</div>
<div id="sample_attach_menu_child">
<a class="sample_attach" href="javascript:alert('Item 1');">Item 1</a>
<a class="sample_attach" href="javascript:alert('Item 2');">Item 2</a>
<a class="sample_attach" href="javascript:alert('Item 3');">Item 3</a>
</div>
<script type="text/javascript">
at_attach("sample_attach_menu_parent", "sample_attach_menu_child", "hover", "y", "pointer");
</script>
<!-- ***** Search Form ***************************************************** -->
<br /><br /><br /><br /><br />
<div  class="sample_attach" id="sample_attach_src_parent">Site Search</div>
<form class="sample_attach" id="sample_attach_src_child" action="sample.html">
<div>
<b>Enter search terms:</b><br />
<input class="sample_attach" type="text" name="terms" /><br />
<input type="submit" value="Submit" />
</div>
</form>
<script type="text/javascript">
at_attach("sample_attach_src_parent", "sample_attach_src_child", "click", "x", "pointer");
</script>
</div>
</body>
</html>



Read More - Drop down Menu and Drop down Search Box