vlg77 free asked 1 year ago


I show products using the database table and in order to edit them I need a modal window that I create using PHP, but for some reason the scripts give an error.

<script>
    const columns = [
        { label: 'Название', field: 'tov_name', sort: true },
        { label: 'OEM', field: 'oem', sort: true },
        { label: 'Описание', field: 'tov_desc', sort: true },
        { label: 'Категория', field: 'category', sort: true },
        { label: 'Курс', field: 'curs_r', sort: true },
        { label: 'Цена', field: 'tov_sum', sort: true },
        { label: 'Модель', field: 'model', sort: true },
        { label: 'Установка', field: 'instloc', sort: true },
        { label: 'Характеристики', field: 'charact', sort: true },
        { label: '', field: 'button', sort: false }
    ];
    const asyncTable = new mdb.Datatable(
        document.getElementById('datatable'),
        { columns, },
        { loading: true }
    );
    fetch('http://localhost/clips/admin/html/json_tovar.php')
    .then((response) => response.json())
    .then((data) => {
        asyncTable.update(
        {
            rows: data.map((user) => ({
                oem: user.oem,
                tov_name: user.tov_name,
                tov_desc: user.tov_desc,
                category: user.category,
                curs_r: user.curs_r,
                tov_sum: user.tov_sum,
                model: user.model,
                instloc: user.instloc,
                charact: user.charact,
                button: `<a data-mdb-toggle="modal" data-mdb-target="#tovarMD`+user.id+`"><i class="fa-solid fa-pen-to-square"></i></a>`
            })),
        },
        { loading: false }
        );
    });
</script>
<script src="../../js/jquery-3.6.0.js"></script>
<script>
    $("#tovsmd").load("json_tovarmd.php");
</script>
PHP down
<div class='modal fade' id='tovarsMD".$tovarmd_list["id"]."' tabindex='-1' aria-labelledby='tovarsMDLB".$tovarmd_list["id"]."' aria-hidden='true'>
        <div class='modal-dialog'>
            <div class='modal-content'>
                <div class='modal-header'>
                    <h5 class='modal-title' id='tovarsMDLB".$tovarmd_list["id"]."'>Modal title</h5>
                    <button type='button' class='btn-close' data-mdb-dismiss='modal' aria-label='Close'></button>
                </div>
                <div class='modal-body'>".$tovarmd_list["tov_name"]."</div>
            </div>
        </div>
    </div>

Grzegorz Bujański staff commented 1 year ago

What error exactly? Can you create a snippet where we can reproduce this error?



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Opened

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB Standard
  • MDB Version: MDB5 6.3.0
  • Device: PC
  • Browser: Chrome
  • OS: Windows
  • Provided sample code: No
  • Provided link: No