Yes you can. However, all of the controls are accessible already through document.forms['formname'].controlname.
Maybe you want to do something that just grabs the text boxes on a page. This is one way you could do it:
function getTextboxes(form_name) {
var tb=new Array();
var i,j;
for (i=0,j=0;i<document.forms[form_name].elements.length;++i) {
if (document.forms[form_name].elements.type=="text" {
tb[j++]=document.forms[form_name].elements;
}
}
return tb;
}
This is a pretty basic example, but it should illustrate the point. If you assign the return value of getTextBoxes to a variable, you can then access that variable to make changes to a given text box (the variable holds a reference to the actual text box).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.