Search code examples
javascriptjqueryhiddenfield

How to get the values from jQuery and assign it for hidden field and save it into the DB?


How to get the values from jQuery and assign it for hidden field and save it into the DB?

Actually I am developing a project, where there is some jQuery code for a button:

$(document).ready(function () {
    $("#btnYes").click(function () {
        $("#btnYes").html("Counted");
        $("#<%= hdnYesNoAnswer.ClientID %>").val("Yes");
        $('#txtComment').focus();
    });
});

When I clicked the #btnYes, it changes to "Clicked". In that page I added one hidden field called #hdnYesNoAnswer. So now what I want is to get the value ("Yes") from that jQuery function and assign it to hidden field #hdnYesNoAnswer and save that hidden field value to the SQL Server database.


Solution

  • @Maris is right. Ajax is a defacto technic for these actions. Here are some links. I hope they help

    http://api.jquery.com/jquery.ajax/

    http://en.wikipedia.org/wiki/Ajax_(programming)

    https://developer.mozilla.org/en/docs/AJAX