When you run this improved page, it will look like this:

function NameAndStateSearch_Or(lname STRING in,
state CHAR(2) in, customer Customer[])
get customer with
#sql{
select
CUSTOMERID, FIRSTNAME, LASTNAME, PASSWORD, PHONE,
EMAILADDRESS, STREET, APARTMENT, CITY, "STATE",
POSTALCODE, DIRECTIONS
from EGL.CUSTOMER
where LASTNAME like :lname
or "STATE" = :state
order by
CUSTOMERID asc
};
end
This function is identical to the NameAndStateSearch_And function you added in the previous lesson, except that it uses OR instead of AND in the where statement.
Here is the complete code of the SearchLibrary.egl file. If you see any errors marked by red X symbols in the file, make sure your code matches the code in this file:Completed SearchLibrary.egl file after lesson 3.
AND
AND
OR
The properties view looks like this when you have finished:

andOr CHAR(3);
Later, you will bind this variable to the radio buttons.
It holds the value "AND" or "OR," depending on which radio button
you select on the page. if (andOr == "AND")
SearchLibrary.NameAndStateSearch_And(
searchTerms.LastName,
searchTerms.State, searchResults);
else
SearchLibrary.NameAndStateSearch_Or(
searchTerms.LastName,
searchTerms.State, searchResults);
end
function searchFunction()
searchTerms.LastName = searchTerms.LastName+"%";
if (andOr == "AND")
SearchLibrary.NameAndStateSearch_And(
searchTerms.LastName,
searchTerms.State, searchResults);
else
SearchLibrary.NameAndStateSearch_Or(
searchTerms.LastName,
searchTerms.State, searchResults);
end
resultMessage = " customer(s) found.";
numberOfResults = searchResults.getSize();
end
This function now calls different functions depending on the value of the andOr variable.
When you test the page, try using the new radio button functions. You must select one of the radio buttons for the search page to work properly.
This search page is still difficult to use because there are not many records in the sample database and many states to guess from. In the next lesson, you will change the State input field to a combo box that lists all of the states used in the database.
Here is the complete code of the customersearch.egl file. If you see any errors marked by red X symbols in the file, make sure your code matches the code in this file:Completed customersearch.egl file after lesson 3.