【发布时间】:2021-08-21 00:08:47
【问题描述】:
我想知道以下是否可能。
我从 SQL 数据库中获取名称列表作为数组。我需要将所有这些名称都用 html 表单一一发布。此操作应通过一个按钮激活。单击按钮时,应一一发布名称,直到发布所有名称,然后停止。所以需要探测的 jquery 或 javascript,但这对我来说是新的。我一直在搜索,但找不到任何可以帮助我完成此任务的内容。
很抱歉问这个问题和我的语言(英语不是我的主要语言),但我不知道这是否可能,我在研究时找不到任何相应的主题..
PS:我不能使用 Ajax 来发帖!!
获取名称的示例:
$stmt = $mysqli->prepare("SELECT username FROM example WHERE examplefield = 1");
$stmt->execute();
$result = $stmt->get_result(); //only works when nd_mysli is set on the server!
while ($rowid = $result->fetch_assoc())
{
$arrayusername[] = $rowid['username'];
}
我需要$arrayusername[] 中的所有姓名,通过按下以下按钮,一一发布到下面的表格中
<input type="button" value="Post all names one by one"
onClick="sendallvalues('???') "class="example_c" />
// 按钮应该做如下帖子名 1, end.帖子名称 2 结束,帖子名称 3 结束。发布所有名称后停止脚本。
<form method="post" target="_example" action="https://www.example.nl">
<input type="hidden" value="<?= $arrayusername[] ?>" name="postvalue" >
</form>
// 应该对用户隐藏,只是为了让名称属性占有一席之地!只需按下一个按钮,所有事情都需要发生!
<script>
function sendallvalues(???) {
//I have no Idea where to begin to make this happen.. But it should post the form one by one with one value at the time untill all names are posted.
}
</script>
【问题讨论】:
-
没有人可以帮忙吗?:(
-
我会尽力帮助你。我认为您需要一个 for 循环来创建输入隐藏字段。
标签: javascript jquery mysql