jeudi 27 avril 2017

How to update input text with save button

I'm trying to create two buttons: an edit and a save button. I have already figured out the edit one, but I need help on the save button. When the user clicks 'save', whatever text they inputted will save to the database. How can I get this to work? All help is appreciated!

CODE:

function setBindings() {
    $(".account").click(function (e) {
        var ui = DATA.getUserInfo();
        if($.isEmptyObject(ui)){
            swal("Oops...", "You need to sign in!", "error");
        }else{
            $(".home").html('<label>Name:</label><input id="editInput" onClick="check()" disabled="true" id="userFullName" value="' + ui.fullName +'" type="text"><button class="edit">Edit</button><button class="save">Save</button>');
            $(".edit").click(function (e) {
                //here is where you want to change the disable to true
                $("#editInput").prop('disabled',false);
            });

            $(".save").click(function (e) {
               //here is where you will update the user information in the database

                function check() {
                    document.getElementById('editInput').value = '';
                }

            })
        }

Aucun commentaire:

Enregistrer un commentaire