So I have a search input field and a working search function.
search result = db.Recipes.Where(r => r.Ingredients.Any(i => FilteredsearchString.Contains(i.IngredientName)));
But I want to make it possible to select items from a checkbox list displayed on the page so they would be added to the input field when checked and removed when unchecked.
foreach (var ingredient in ingredients)
{
if (@ingredient.IngredientCategory == 0)
{
<label class="btn btn-primary veggies">
<input type="checkbox"
name="selectedIngredients"
class="badgebox"
value="@ingredient.IngredientID" />
@ingredient.IngredientName
<span class="badge">✓</span>
</label>
}
}
The checkbox fields are generated using ingredients from the database. What would be the best way to do this ?
Aucun commentaire:
Enregistrer un commentaire