26-6-2011
jQuery
$(‘textarea’).each(function(){ // get current number of characters var length = $(this).val().length; // get current number of words //var length = $(this).val().split(/\b[\s,\.-:;]*/).length; // update characters $(this).parent().find(‘.counter’).html( 4000 – length + ‘ characters left’); // bind on key up event $(this).keyup(function(){ // get new length of characters var new_length = $(this).val().length;? // get new length of words //var n ..
Read more
26-6-2011
jQuery
Just a quick and smooth snippet to go to the top of page with jQuery.
<script type="text/javascript"> $(document).ready(function() { $(‘.backtotop’).click(function(){ $(‘html, body’).animate({scrollTop:0}, ‘slow’); }); }); </script > ..
Read more
11-5-2011
UIAlertView *someError = [[UIAlertView alloc] initWithTitle: @"Network error" message: @"Error sending your info to the server" delegate: self cancelButtonTitle: @"Ok" otherButtonTitles: nil];
[someError show];
[someError release]; ..
Read more
29-6-2010
Use onchange to alert the customer that a charge will occur and then the function doMath() calculates the surcharge. JavaScript
<script type="text/javascript"> function checkSel(obj) { var ind = obj.selectedIndex; if (ind == 3) { alert(‘This Card incurs a 3.5% Surcharge.’); } } function doMath() { if (CardType = "AMEX") { var one = eval(document.catwebformform7818.Amount.value) var prod = one * 1.03 document.catwebformform7818.Amount.value=custRound(prod,2);} } functi ..
Read more
28-6-2010
jQuery
<script type="text/javascript"> jQuery.preloadImages = function(){ for(var i = 0; i< arguments.length;> < /arguments.length;> { jQuery("< img alt="" />").attr("src", arguments[i]); } }; // use like $.preloadImages("image0001.jpg", "/path/to/image0002.jpg", "some/image0003.jpg"); </script> ..
Read more