我想从一个foreach循环中创建一个包含约300个文本框的页面。我能够将链接写入文本框,但无法读取文本框数组。按钮不起作用。如何通过按钮提交这些链接?

echo "<form><input style='width:1000px' type='text' name='link[]' value='https://example.com/api/user_api.php?request=SellItem&amount=" . $number . "&featured=0&classid=" . $item["classid"] . "&instanceid=" . $item["instanceid"] . "&key=xxx'". "<br>";
echo "<input name='Launchlink[]' type='button' value='Send' onclick='location.href=this.form.elements['link[]'].value'></form>'";

最佳答案

根据您的评论

var links = <?=json_encode($the_link_array)?>;
function open_all_of_the_links(){
    for (var i = 0; i < links.length; ++i) {
        window.open(links[i], "_blank");
    }
}
document.getElementById("theButton").addEventListener("click", open_all_of_the_links);


然后,您可以拥有ID为“ theButton”的任何内容,这将在其上注册一个事件,并应在新选项卡中打开所有URL。

<span id="theButton">Click here to make all of your dreams come true</span>

07-24 09:38
查看更多