Archive for the ‘Javascript’

  • Traversing DOM using JavaScript
    The HTML DOM defines a standard way for accessing and manipulating HTML documents. The DOM presents an HTML document as a tree-structure expressed as an XML document. DOM is a language independent API, as it can be used in Java, .NET, JavaScript and many more. I will use it with JavaScript to for my sample code provided below. When talking about DOM trees , you are really...
    by Nauman at November 22nd, 2009 at 12:11 am
  • RGB-to-Hex Conversion
    Question is: How do I convert RGB values of a color to a hexadecimal string? The algorithm is as follows: make sure that RGB values are in the range 0…255, convert RGB values to hex strings, and then merge the three strings. Here is a script that does this conversion: function RGBtoHex(R,G,B) { return toHex(R)+toHex(G)+toHex(B); } function toHex(N)...
    by saim at November 3rd, 2009 at 08:11 am
  • charachter validation and count for a textbox – Javascript
    Here I have provided a solution to put a counter for a textbox, that can be updated as each character typed into the textbox. This script will also validate the maximum character length allowed for a textbox. This script will also work when anyone copy/paste the text into the textbox. Textbox can be either single line or multi line. Check the following script: <!–[if...
    by Nauman at November 3rd, 2009 at 07:11 am
  • Enable/Disable DIV tags through Javascript
    Copy/Paste following javascript code snippet. <script type="text/javascript"> function toggleAlert() { toggleDisabled(document.getElementById("content")); } function toggleDisabled(el) { try { el.disabled = el.disabled ? false : true; } catch(E){ } if (el.childNodes && el.childNodes.length...
    by Nauman at November 3rd, 2009 at 07:11 am