Feed on
Posts
Comments

Archive for the 'JavaScript' Category

LTrim() RTrim() Trim()

To use these, just call LTrim(), RTrim(), or Trim() with the string you want trimmed. <script type=”text/javascript”> <!– function LTrim(trimInputString) { while(trimInputString.charAt(0)==” “) trimInputString=trimInputString.substring(1,trimInputString.length); return (trimInputString); } function RTrim(trimInputString) { while(trimInputString.charAt(trimInputString.length-1)==” “) trimInputString=trimInputString.substring(0,trimInputString.length-1); return (trimInputString); } function Trim(trimInputString) { while(trimInputString.charAt(0)==” “) trimInputString=trimInputString.substring(1,trimInputString.length); while(trimInputString.charAt(trimInputString.length-1)==” “) trimInputString=trimInputString.substring(0,trimInputString.length-1); return (trimInputString); } //–> </script>

Read Full Post »

List Last x Days

To show the dates for Today – x days, set the value of x accordingly. <script type=”text/javascript”> <!– DateToday = new Date(); x=7; for (y=0; y<x; y++) { MyDate = new Date(Date.UTC(parseInt( _ DateToday.getYear()), _ parseInt(DateToday.getMonth()), _ parseInt(DateToday.getDate()))- _ (60*60*24*1000*y)); MyDateString=MyDate.getDate() + ‘.’ _ + parseInt(MyDate.getMonth()+1) _ + ‘.’ + MyDate.getYear(); document.write (MyDateString + “<br>”); [...]

Read Full Post »

isInArray()

If you want to check whether a particular value is in an array, call this function with something like this. if (isInArray(MyValue, MyArray)) <script type=”text/javascript”> <!– function isInArray(needle, arrayHaystack) { for (x=0; x < arrayHaystack.length; x++) if (arrayHaystack[x] == needle) return true; return false; } –> </script>

Read Full Post »

Get a value from an NVP String

To use this, call GetNVP(string NVPString, string NVPid) with the input NVP string and the name of the value you want to retrieve. <script type=”text/javascript”> <!– function GetNVP(NVPString,NVPid) { var NVPFound=false; var NVPArray=new Array(); var NVPList=NVPString.split(‘&’); for (x=0; x<NVPList.length; x++) { NVPData=NVPList[x].split(‘=’); NVPArray[NVPData[0>=NVPData[1]; } for (var LocalID in NVPArray) if(NVPid==LocalID) NVPFound=true; if (NVPFound) return (NVPArray[NVPid]); [...]

Read Full Post »

Date Difference in Days

To use this, just call CountDays() with two properly formatted date values. <script type=”text/javascript”> <!– function CountDays(StartDate,EndDate) { var StartMS=Date.parse(new Date(StartDate)); var DateMS=Date.parse((EndDate)); return parseInt(DateMS-StartMS)/86400000; } var StartDate=’May 01, 2001 00:00:00′; var EndDate=’May 17, 2001 00:00:00′; document.write (CountDays(StartDate,EndDate)); //–> </script>

Read Full Post »

Blink Text

Flashing text is crap. Don’t do it.   This code needs a <div> to contain the text you want to flash, and is called in the ‘onLoad’ event of the <body> tag with something like <body onLoad=”Blink(‘LayerName’);”> <script type=”text/javascript”> <!– function Blink(BlinkID) { BlinkLayer = document.getElementById(BlinkID); if (BlinkLayer.style.color==\’#880000\’ || BlinkLayer.style.color==\’rgb(136, 0, 0)\’ || BlinkLayer.style.color==\’rgb(136,0,0)\’) BlinkLayer.style.color=\’#000088\’; [...]

Read Full Post »