Posted by admin on February 24, 2010 – 11:57 pm
Author: slac3dork
Site: http://snippet.c0de.me
Summary: Click counter with jQuery framework.
<html>
<head>
<title>Twitter like text area</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
var total_click = 0;
$("#clickMe").click(function(){
total_click = total_click + 1;
$("#counter").text("Total Click: " + total_click);
return false;
});
});
</script>
</head>
<body>
<form>
<div id="counter">Total Click: 0</div><br />
<a id="clickMe" href="#">click me!</a>
</form>
</body>
</html>

Posted by admin on January 16, 2010 – 6:21 pm
Author: slac3dork
Site: http://snippet.c0de.me
Summary: This script will disable “Go!” button if total characters more than 140 or have no character using jQuery framework.
<html>
<head>
<title>Twitter like text area</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$("#my-submit-id").attr("disabled", "disabled");
var chars = 0;
$("#my-text-id").keyup(function(){
chars = $(this).val().length;
if ((chars < 1) || (chars > 140)){
$("#my-submit-id").attr("disabled", "disabled");
}
else {
$("#my-submit-id").removeAttr("disabled");
}
$("#my-label").text("Total characters: " + chars);
});
});
</script>
</head>
<body>
<form>
<label id="my-label">Total characters: 0</label><br />
<textarea id="my-text-id" name="my-text" rows="5" cols="20">
</textarea><br />
<input id="my-submit-id" type="submit" value="Go!" />
</form>
</body>
</html>

Posted by admin on July 22, 2009 – 4:59 pm
Author: slac3dork
Site: http://snippet.c0de.me
Summary: A simple slide show image using javascript. You must define all your images path.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0.1//EN">
<html>
<head>
<title>Simple Image Slide Show</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
/*
_________ .__ .____ _______
/ _____/ ____ |__|_____ | | \ _ \ ____
\_____ \ / \| \____ \| | / /_\ \ / ___\
/ \ | \ | |_> > |__\ \_/ \/ /_/ >
/_______ /___| /__| __/|_______ \_____ /\___ /
\/ \/ |__| \/ \//_____/
http://snippet.c0de.me
slac3dork@gmail.com
*/
var i = 0;
var total = 5; // total slide show images
var t = 0;
function initial() {
images[0] = 'path/to/images/1.jpg';
images[1] = 'path/to/images/2.jpg';
images[2] = 'path/to/images/3.jpg';
images[3] = 'path/to/images/4.jpg';
images[4] = 'path/to/images/5.jpg';
}
function timer() {
clearTimeout(t);
t = setTimeout('nextimg()', 3000);
}
function imageError() {
nextimg();
}
function previmg(){
if (i != 0){
i = i - 1;
} else {
i = total;
}
document.banner_show.src = images[i];
}
function nextimg(){
if (i != total){
i = i + 1;
} else {
i = 0;
}
document.banner_show.src = images[i];
}
</script>
</head>
<body>
<img src="path/to/images/1.jpg" onLoad="initial();" onError="imageError" alt="" />
<a onclick="previmg(); return false;">prev</a>
<a onclick="nextimg(); return false;">next</a>
</body>
</html>
