在循环中分配按钮值 - Laravel Blade

问题描述

        @foreach($sections as $section)
            <div class="main_content_body">
                <div class="main_content_bodyhead">
                    <h4>{{ $section->section_name }}</h4>
                    {{ $section->id }}
                    <button id="KNowthesection" value="{{ $section->id }}" type="button" class="button1" data-toggle="modal" data-target="#updatesectionmodal" onclick=getsectionid()>
                        Update section name
                    </button>
                </div>
                <div class="main_content_bodycontent">
                    <td>content 1</td><br><br>
                    <td>content 2</td>
                </div>
            </div>
        @endforeach

<script>
    function getsectionid(){
        var sec_id = document.getElementById('KNowthesection').value;
        alert(sec_id);
    }
</script>

我尝试在循环中为按钮分配值。但是当我提醒价值时。它总是显示一个循环值。按钮上方的 section->id 显示完美,但按钮内的 section->id 却没有。有谁知道原因?我该如何解决。谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)