gpt4 book ai didi

javascript - 语义 UI 下拉表单未发送

转载 作者:行者123 更新时间:2023-11-28 03:45:31 27 4
gpt4 key购买 nike

我得到了以下代码(为了这个问题而缩短)

    $(function() {
var professions = [{"name":"Altenpflegehelfer","value":"3"},{"name":"Altenpfleger","value":"4"},{"name":"Änderungsschneider","value":"2"},{"name":"Anlagenmechaniker","value":"5"},{"name":"Anlagenmechaniker für Sanitär-, Heizungs- und Klimatechnik (früher: Zentralheizungs- und Lüftungsbauer)","value":"6"},{"name":"Asphaltbauer","value":"7"}];

$('#profession').dropdown({
values: professions,
fullTextSearch: true,
});

});
<head>
<!-- jQuery -->
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>

<!-- Semantic UI -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.14/semantic.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.14/semantic.min.css" />
</head>
<body>
<form class="ui large form" action="post.php" method="post">
<div class="one field">
<label for="profession">Profession</label>
<select name="profession" class="ui search dropdown" id="profession"></select>
</div>
<button type="submit" class="ui fluid large teal submit button">Submit</button>
</form>

<script>

</script>
</body>

问题是,当我发送表单时,PHP 中的 $_REQUEST 变量为空。

您可以通过使用以下内容创建新文件 post.php 来简单地测试它:

<?php echo var_dump($_REQUEST); ?>

我做错了什么吗?

最佳答案

$(function() {
var professions = [{"name":"Altenpflegehelfer","value":"3"},{"name":"Altenpfleger","value":"4"},{"name":"Änderungsschneider","value":"2"},{"name":"Anlagenmechaniker","value":"5"},{"name":"Anlagenmechaniker für Sanitär-, Heizungs- und Klimatechnik (früher: Zentralheizungs- und Lüftungsbauer)","value":"6"},{"name":"Asphaltbauer","value":"7"}];

$('.ui.dropdown').dropdown({
placeholder: "Search your profession",
values: professions,
fullTextSearch: true,
});

});
<head>
<!-- jQuery -->
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>

<!-- Semantic UI -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.14/semantic.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.14/semantic.min.css" />
</head>
<body>
<form class="ui large form" action="post.php" method="post">
<div class="field"> <!-- creating a field -->
<label>Profession</label>
<div class="ui search labeled selection dropdown">
<input name="profession" type="hidden"> <!-- store the selected value that gonna be posted -->
<span class="text"></span>
<i class="dropdown icon"></i>
</div>
</div>
<button type="submit" class="ui fluid large teal submit button">Submit</button>
</form>

</body>

关于javascript - 语义 UI 下拉表单未发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48518320/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com