Can someone explain what this function is doing
var page = new Object();
page.testSearch.btnSearch.setState = function() {
this.disable(!(page.testSearch.searchString.value.trim().length > 1));
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The code creates a new empty JavaScript object called page. Then it adds a property to the object (which in this case turns out to be a function). It looks like it is relying on another function which you haven’t pasted in called disable (but I think that we can assume that it disables something in some way!) which will disable something if the text in
page.testSearch.searchStringis shorter than 1 character long.It looks to me like it works on a form on a web page.
It must be said that this style of JavaScript coding is a little out-dated, and some might argue that this piece of code would be better written as using object literal notation.