RSS

Category Archives: javascript

oop javascript

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);
}
 
Leave a comment

Posted by on February 12, 2008 in javascript

 

Reset form by looping through elements

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

 
Leave a comment

Posted by on May 30, 2007 in javascript

 
 
Follow

Get every new post delivered to your Inbox.