Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/410.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Javascript将玩家移动到表单并从表单中移除_Javascript_Python_Html - Fatal编程技术网

使用Javascript将玩家移动到表单并从表单中移除

使用Javascript将玩家移动到表单并从表单中移除,javascript,python,html,Javascript,Python,Html,我需要能够将player.gamer_标记值移动到表单上,禁用按钮以使它们不能再次添加,并使用按钮将它们从表单中删除 我不知道为什么javascript函数没有添加到代码示例中。开始时,在同一级别上有两个s,但外部完全没有插入,代码格式只是因为它从前几行继续应用。然后在标记前出现了一个空行,跳进了块的分离,重新开始了代码格式化。 <div class="container"> <div class="row">

我需要能够将player.gamer_标记值移动到表单上,禁用按钮以使它们不能再次添加,并使用按钮将它们从表单中删除


我不知道为什么javascript函数没有添加到代码示例中。开始时,在同一级别上有两个s,但外部完全没有插入,代码格式只是因为它从前几行继续应用。然后在标记前出现了一个空行,跳进了块的分离,重新开始了代码格式化。
<div class="container">
    <div class="row">
        <div class="column">
            <div class="box" id="players">
                <!-- table
                Gamertag    Team    PPG Value somesortofsubmitbutton
                -->
                <h3>Player Pool</h3>
                <table style="width: 80%;">
                    <tr>
                        <th>Gamertag</th>
                        <th>Team</th>
                        <th>PPG</th>
                        <th>Value</th>
                    </tr>
                    {% for player in playerList %}
                        <tr>
                            <td id="gamerTag">{{ player.gamer_tag }}</td>
                            <td id="team">{{ player.team }}</td>
                            <td id="fppg">{{ player.fppg }}</td>
                            <td id="value">{{ player.value }}</td>
                            <td><button id="selectButton" style="background-color: green;" onclick="addPlayer('{{ player.gamer_tag }}')">Select</button></td>
                        </tr>
                    {% endfor %}
                </table>
            </div>
        </div>
        <div class="column">
            <!-- try using regular html form, post method, grab on python side, may have to let users type until automation
             make input boxes required and use javascript to check for empties-->
            <h3>Lineup</h3>
            <form id="form1" method="POST" action="/lineup-creation">
                <input type="text" id="captain" required placeholder="Captain"><br>
                <input type="text" id="player1" required placeholder="Flex"><br>
                <input type="text" id="player2" required placeholder="Flex"><br>
                <input type="text" id="player3" required placeholder="Flex"><br>
                <input type="text" id="player4" required placeholder="Flex"><br>
                <button type="submit" form="form1" value="Submit">Submit Lineup</button>
            </form>
        </div>
    </div>
</div>

<script type="text/javascript">
    function addPlayer(gamerTag)
    {
        document.getElementById("captain").value = gamerTag;
        document.getElementById("selectButton")[0].setAttribute("disabled", disabled");
    }
    /*$(document).on('click', ':button', function(e){
        var btn = $(e.target);
        btn.attr("disabled", "disabled");
    });*/
</script>