Skip to main content

Adding the Category List

Here, we add the Category drop-down list, filling it using a new query named CategoryName. We define this query in the FilmCategory class. Find the code for CategoryName here:generated description: handson.gif

Note that for each element in the list (each <option> tag) we specify a value, using the object ID, as well as the text to display, using the CategoryName property. We also supply an “any” option, with a value of “*” and text of “Any Category”. Note also that the HTML for Search.csp will not display correctly until the CategoryName query has been defined.

—Search.csp—
Search.csp
<html> <head></head>
<body>
<table width="100%" border="0"> <tr>
    <td><img src="CacheCinemaLogo.gif"></td>
    <td align="right">
    <form 
            name="Search" 
            action="SearchResults.csp" 
            target="Main" 
            method="post">
        <b>Find</b>
        <select name="CategoryList" size="1">
        <option value="*" selected>Any Category</option>
        <csp:query 
                name=CatList 
                classname="Cinema.FilmCategory" 
                queryname="CategoryName">
        <csp:while condition="CatList.Next()">
            <option value=#(CatList.Get("ID"))#>
            #(CatList.Get("CategoryName"))#</option>
        </csp:while>
        </select>
    </form>
    </td> </tr>
</table>
<hr>
</body> </html>
FeedbackOpens in a new tab