<div class="card">
    <div class="card-content">
        <div class="card-body">
            <h4 class="card-title">Add New Note</h4>
        </div>
        <div class="card-body">
            <form class="form">
                <input type="hidden" id='member_id' name='member_id' value="<?= $_SESSION["member_id"] ?>" />
                <input type="hidden" id='page_id' name='page_id' value="<?= $page_id ?>" />

                <div class="form-body">
                    <div class="form-group">
                        <label for="feedback1" class="sr-only">Note Title</label>
                        <input type="text" id="feedback1" class="form-control" placeholder="Title" name="title" value="<?= isset($title) ? $title : '' ?>" required>
                    </div>


                    <div class="form-group">
                        <label for="feedback3" class="sr-only">Note Detail</label>
                        <textarea id="feedback3" rows="6" class="form-control" name="detail" placeholder="Note Detail" required=""><?= isset($details) ? $details : '' ?></textarea>
                    </div>
                </div>

                <div class="form-actions" style="text-align: right;">
                    <div id="save_detail"></div>  <button type="submit" class="btn btn-primary mr-1" id="pagebt" onclick="return addNewItem(this.form);">Add Note</button>
                </div>
            </form>
        </div>
    </div>
</div>
</div>



<script type="text/javascript">
    let member_id = '<?= $_SESSION["member_id"] ?>';

    function addNewItem(form) {
        $('#save_detail').html('Saving');
        $('#pagebt').prop('disabled', true);

        //alert(form.member_id.value);
        var post_data = {
            'member_id': form.member_id.value,
            'title': form.title.value,
            'detail': form.detail.value,
            'page_id': form.page_id.value
        };
        // alert(1);
        // Get some values from elements on the page:
        var url = "/member/addNotecard";
        // Send the data using post
        var posting = $.post(url, post_data);
        // Put the results in a div
        posting.done(function (data) {
            $('#save_detail').html(data);
            $('#pagebt').prop('disabled', false);
        });
        return false;
    }
</script>