我想知道是否有使用样式列表作为选择框进行表单输入的麻烦。或者,如果有任何类似的解决方案,您可以在样式中选择带有图标等的选择框。因为我的PHP验证失败。
PHP
// Validate prioriteta
if(empty(trim($_POST["prioriteta"]))){
$prioriteta_err = "Prosim izberite prioriteto.";
} else{
// Prepare a select statement
$sql = "SELECT id FROM tasks WHERE prioriteta = ?";
if($stmt = mysqli_prepare($link, $sql)){
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "s", $param_prioriteta);
// Set parameters
$param_prioriteta = trim($_POST["prioriteta"]);
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt)){
/* store result */
mysqli_stmt_store_result($stmt);
$prioriteta = trim($_POST["prioriteta"]);
} else{
echo "Oops! Something went wrong. Please try again later.";
}
}
// Close statement
mysqli_stmt_close($stmt);
}
HTML
<input type="hidden" list="seznam" name="prioriteta" value="<?php echo $prioriteta; ?>">
<small class="text-muted control "><?php echo $prioriteta_err; ?></small>
<ul id="seznam" class="dropdown-menu">
<li><i class="far fa-circle red pr-2" value="ZP"></i>Very High</li>
<li><i class="far fa-circle purple pr-2" value="PO"></i>High</li>
<li><i class="far fa-circle aquamarine pr-2" value="SR"></i>Mid</li>
<li><i class="far fa-circle med-gray pr-2" value="NI"></i>Low</li>
</ul>
答案 0 :(得分:1)
使用不可见的输入字段,然后在列表项上单击获取值并将其插入输入字段。
HTML:
<input type="hidden" name="prioriteta" value="<?php echo $prioriteta; ?>"
JQUERY:
$( document ).ready(function() {
$( "#other" ).click(function() {
$( "#target" ).val();
});
});