Archive

Archive for the ‘javascript’ Category

oop javascript

February 12, 2008 varnit Leave a comment
function Car (pMake, pModel, pColor){
this.make = pMake
this.model = pModel
this.color = pColor
}
Car.prototype.showCar = function {
alert(this.make + ” ” + this.model + ” ” + this.color);
}
Categories: javascript

Reset form by looping through elements

May 30, 2007 varnit Leave a comment

Function to reset form values.

function resetForm(theForm){
    for(i=0; i<theForm.elements.length; i++)
    {
        if(theForm.elements[i].type == "text")
        {
            theForm.elements[i].value = '';
        }
        else if(theForm.elements[i].type == "select-one")
        {
            theForm.elements[i].selectedIndex = 0;
        }
    }
}

other possible form elements: textarea, checkbox

Categories: javascript