Archive for the ‘ Javascript ’ Category
"Most people getting started with JavaScript these days are faced with the challenging task of picking a library to use, or at least which one to learn first. If you're working for a company chances are they have already chosen a framework for you, in which case the point is somewhat moot. If this is the case and they've chosen MooTools and you're used to jQuery, then this article might still be of some use to you. " Written by Aaron Newton Article here: http://jqueryvsmootools.com[ READ MORE ]
This is a simple script that will highlight required fields on a form. It requires no libraries and is just one simple function that accepts an array of field id's that are required. Code: function checkRequiredFields(fieldIdsArray){ var fields = fieldIdsArray; var errorThrown = false; for (var i = 0; i < fields.length; i++){ var obj = document.getElementById(fields[i]); if (obj.value == '' || obj.value == null){ obj.style.border = '1px solid red'; obj.onfocus = function(){ this.style.border = '1px solid #999999'}; [ READ MORE ]
function checkRequiredFields(fieldIdsArray){ var fields = fieldIdsArray; var errorThrown = false; for (var i = 0; i < fields.length; i++){ var obj = document.getElementById(fields[i]); if (obj.value == '' || obj.value == null){ obj.style.border = '1px solid red'; obj.onfocus = function(){ this.style.border = '1px solid #999999'}; [ READ MORE ]
A simple javascript snippet to remove HTML elements dynamically. function removeElement(elementId){ var itemToBeRemoved = document.getElementById(elementId); var parent = itemToBeRemoved.parentNode; parent.removeChild(itemToBeRemoved); }; [ READ MORE ]
function removeElement(elementId){ var itemToBeRemoved = document.getElementById(elementId); var parent = itemToBeRemoved.parentNode; parent.removeChild(itemToBeRemoved); };
function showPopup(textBox, className){ // grab the textbox object var textbox = document.getElementById(textBox); // get the textboxes parent var parent = textbox.parentNode; // check to see if this popup is already on screen var popup = document.getElementById(textBox + '_popup'); if (!popup) { // we don't have a popup, lets create one // create popup div var popup = document.createElement('div'); // give it a unique id popup.id = textBox + '_popup'; // attach css if passed in [ READ MORE ]