lundi 24 juillet 2017

Add value in textbox on checkbox check

I've got 3 checkboxes and I want to fill in a database query based on the checked checkboxes. What I've got so far is , just enough for it to search based on 1 of the textboxes, but I want to be able to add unlimited amounts of categories to search from.

Here are my 3 checkboxes:

<input type="checkbox" id="CorrectionConsultantYN" value="60" />
<input type="checkbox" id="ProcessingAnalyzYN" value="10" />
<input type="checkbox" id="ProcessingConsultantYN" value="0" />

Here's my textbox:

<asp:TextBox ID="SearchValue" ClientIDMode="Static" runat="server" class="form-control form-control-pireus"></asp:TextBox>

And my function so far:

$("[type=checkbox]").change(function () {
    if ($(this).is(':checked')) {
        $("#SearchValue").val($(this).val());
    }
    else {
        $("#SearchValue").val();
    }
});

What I want the final result to be is something like select * from something where there's textbox 1 value, textbox 2 value and so on.




Aucun commentaire:

Enregistrer un commentaire