I have two functions which do pretty much the same thing. Take a look at the code first:
- Code: Select all
/*OnFocus text in SearchBox removed, OnBlur text is re-added to textbox*/
function SearchBox(nm) { nm.value != 'Search Contacts' && nm.value != '' ? nm /*Do Nothing*/ : nm.value = ''; }
function SearchBoxBlur(nm) { nm.value == '' ? nm.value = 'Search Contacts' : nm /*Do Nothing*/; }
/*Same as above two function except for header search box*/
function SearchBox2(nm) { nm.value != 'Search Letters' && nm.value != '' ? nm /*Do Nothing*/ : nm.value = ''; }
function SearchBoxBlur2(nm) { nm.value == '' ? nm.value = 'Search Letters' : nm /*Do Nothing*/; }
For one of the search boxes the value is "Search Letters" the other is "Search Contacts". I tried to consolidate it into one function and use an OR for the two different possilibities but that didnt work (Didnt give any errors either). How can I make the code more efficient ?
.


