Q: Mixing javascript and C# I have @model IEnumerable<HotelWithRating> - some hotels.
At the view I have 5 checkboxes - stars of the hotel.
<table>
    <tr>
        <td>1</td>
        <td>2</td>
        <td>3</td>
        <td>4</td>
        <td>5</td>
    </tr>
    <tr>
        <td><input type = 'checkbox' value="false" id= '1' onclick = ' ShowHotels();'/></td>
        <td><input type = 'checkbox' value="false" id= '2' onclick = ' ShowHotels();'/></td>
        <td><input type = 'checkbox' value="false" id= '3' onclick = ' ShowHotels();'/></td>
        <td><input type = 'checkbox' value="false" id= '4' onclick = ' ShowHotels();'/></td>
        <td><input type = 'checkbox' value="false" id= '5' onclick = ' ShowHotels();'/></td>
    </tr>
</table>

I need that hotels to be displayed which has for example 5 or 4 stars (if forth and fifth checkboxes are checked).
It should be something like this 
<table class="Grid"> 
    <tr> 
        <th>Name</th>
        <th>Stars</th>       
        <th>Rating</th>
        <th>Description</th>             
    </tr> 
    <script type="text/javascript">
        function ShowHotels() 
        {
              @foreach (var item in Model)
                  {
                      <text>
                      if (document.getElementById(item.Hotel.stars).checked == true)
                      {
                          <tr>
                          <td>@item.Hotel.Name</td>
                          <td>@item.Hotel.Stars</td>
                          <td>@item.Rating</td>
                          <td>@item.Hotel.Description</td>
                          </tr>
                      }
                      </text>
                  }
        }
    </script>
</table>

I have found many topics about mixing javascript with code but still haven't an decision.

A: Better first you filter the model based on the check box selection. It can be done on client side by comparing the property of each hotel in model. Otherwise you can do server side filtering too, using AJAX (sending the info of selected check box and then server will send you filtered model). Server side filtering is better is you have huge list of hotels to be look into.
Then assign this filtered model to the Grid or generate the table using for loop for every element in filtered model using JavaScript.
Feel free to ask any further question if you get. Thanks.
