Php 通过POST从select获取所有选项
我正在构建一个页面,其中有两个选择框。我添加项目以从选择1中选择2 单击“提交”按钮时,我只想从“选择2”获取所有选项,无论它们是否被选中Php 通过POST从select获取所有选项,php,html,drop-down-menu,Php,Html,Drop Down Menu,我正在构建一个页面,其中有两个选择框。我添加项目以从选择1中选择2 单击“提交”按钮时,我只想从“选择2”获取所有选项,无论它们是否被选中 <?php require('handlers/handler.php'); $active = $_POST['activeProperties']; $slider = $_POST['sliderProperties']; $array = array(); if(isset($_POST['submit'])){ if(isset($_
<?php
require('handlers/handler.php');
$active = $_POST['activeProperties'];
$slider = $_POST['sliderProperties'];
$array = array();
if(isset($_POST['submit'])){
if(isset($_POST['sliderProperties'])){
foreach($_POST['sliderProperties'] as $item){
$array[] = $item;
}
}
echo "<pre>";
print_r($array);
echo "</pre>";
}
?>
<form method="post" style="height: 600px;">
<select id="source" name="activeProperties[]" data-text="Source list" data-search="Search for options" style="height: 600px;">
<?php
$query = $handler11->query("SELECT ID, name FROM properties WHERE active = 'yes' ");
while($row = $query->fetch()){
echo '<option value="'.$row['ID'].'">'.$row['name'].'</option>';
}
?>
</select>
<select id="destination" name="sliderProperties[]" data-text="Destination list" data-search="Search for options">
</select>
<input type="submit" name="submit" class="btn btn-primary" value="Save"/>
</form>
我只得到带有此代码的选择框中的第一项。如何获取所有项目?如果您希望所有数据都被选中或未选中,您不能通过此查询在php中获得相同的结果:
$query=$handler11->querySELECT ID,name FROM properties WHERE active='yes' 如果您想要所有数据(无论是否选中),您不能通过此查询在php中获得相同的结果:
$query=$handler11->querySELECT ID,name FROM properties WHERE active='yes' 您可以使用多选HTML文档,请尝试以下操作:
另一个选项是通过Javascript执行。您可以使用多选HTML文档,请尝试以下操作:
另一个选项是通过Javascript执行。您没有在数据库中选择feld1,或者需要使用$row['name'],这取决于哪个选项是正确的,这是一个输入错误。对不起……第一个选项是从数据库填充的。如何从destination select(目标选择)获取所有选项(无论是否选中)?您没有在数据库中选择feld1,或者您需要使用$row['name']取决于哪个选项是正确的,这是一个输入错误对不起…第一个选择是从数据库填充的。如何从destination select(目标选择)获取所有选项(无论是否选中)?我传递到目标选择的所有数据我传递到目标选择的所有数据
<form method="post" style="height: 600px;">
<select multiple id="source" name="activeProperties[]" data-text="Source list" data-search="Search for options" style="height: 600px;">
<?php
$query = $handler11->query("SELECT ID, name FROM properties WHERE active = 'yes' ");
while($row = $query->fetch()){
echo '<option value="'.$row['ID'].'">'.$row['name'].'</option>';
}
?>
</select>
</form>