提取后如何使用函数

时间:2019-04-26 08:25:42

标签: javascript

在使用带有返回的fetch之后如何使用函数?

在onchange事件中,我已发出警报,但未运行。使用抓取刷新页面后。

<select name="Request_keuzen" id="request_keuzen" class="form form-control" onchange="update_request_keuze_1(this.value)">
                        <option value="<?php echo $request_keuze_1 ?>"><?php echo $request_keuze_1 ?></option>
                        <?php
                        while ($row5 = mysqli_fetch_assoc($result5)):; ?>
                            <option value="<?php echo $row5['naam']; ?>"><?php echo $row5['naam']; ?></option>
<?php endwhile; ?>
</select>
function iso_nummer_content(isonumer) {

        const data = new FormData();

        let lisl_lijst_nummer = document.getElementById("lisl_lijst_nummer").value;

        data.set("lisl_lijst_nummer", lisl_lijst_nummer);
        data.set("isonummer", isonumer);

        fetch("Fill_lisl_list2_items.php", {method: 'POST', body: data})
            .then(response => response.text())
            .then(tekst => document.getElementById("scriptophalen").innerHTML = tekst);
    }
function update_request_keuze_1(str) {

        const data = new FormData();

        let selection = str;
        let id = document.getElementById("id").value;

        data.set("request_keuze_1", selection);
        data.set("id", id);

        fetch("Update_lisl_list_item_request_keuze_1.php", {method: 'POST', body: data})
    }

预期结果:

使用访存并重新加载页面后,我仍然可以使用函数update_request_keuze_1。

已修复:

 function update_request_keuze_1() {

        var table = document.getElementById('tabel_lisl_lijst_fase_2');

        for (var i = 1; i < table.rows.length; i++) {
            table.rows[i].onclick = function () {
                let id = this.cells[1].innerHTML;
                let selection = this.cells[18].children[0].value;

                const data = new FormData();

                data.set("request_keuze_1", selection);
                data.set("id", id);

                fetch("Update_lisl_list_item_request_keuze_1.php", {method: 'POST', body: data})
            }
        }
    }

0 个答案:

没有答案