禁用的表单元素能否与启用的表单元素共享一列?

sy5wg1nm  于 2021-06-18  发布在  Mysql
关注(0)|答案(1)|浏览(263)

禁用的表单元素能否与启用的表单元素共享列?
我有一个表单,它有4组组合框,这些组合框中填充了另一个表中的数据,只有在进行某些选择时才可见并处于活动状态,每组组合框包含4个可能的选项集,其中一个选项集或一个选项集不可见且一次处于活动状态,我已经将每组组合框设置为保存到同一个表列中,因为在任何时候只有一个组合框在工作,所以在筛选数据时,每组选项的4个独立列都太复杂了(至少在我看来是这样)。
我遇到的问题是,我得到的是一个保存到数据库表中的空值,而不是所选的值,我把下面的编码,以帮助解释我试图做什么。
表单编码可见/活动选项

<select name="Lab1" id="Lab1" style="visibility:hidden;" onChange="if (this.value=='Alpha Bio Labs'){this.form['Samp1'].style.visibility='visible'}
              if (this.value=='Alpha Bio Labs'){this.form['Samp1'].disabled=false}
              if (this.value=='Alpha Bio Labs'){this.form['Samp2'].style.visibility='hidden'}
              if (this.value=='Alpha Bio Labs'){this.form['Samp2'].disabled=true}
              if (this.value=='Alpha Bio Labs'){this.form['Samp3'].style.visibility='hidden'}
              if (this.value=='Alpha Bio Labs'){this.form['Samp3'].disabled=true}
              if (this.value=='Alpha Bio Labs'){this.form['Samp4'].style.visibility='hidden'}
              if (this.value=='Alpha Bio Labs'){this.form['Samp4'].disabled=true}
              if (this.value=='Alpha Bio Labs'){this.form['SegmCol1'].style.visibility='visible'}
              if (this.value=='Alpha Bio Labs'){this.form['SegmCol1'].disabled=false}
              if (this.value=='Cellmark'){this.form['Samp1'].style.visibility='hidden'}
              if (this.value=='Cellmark'){this.form['Samp1'].disabled=true}
              if (this.value=='Cellmark'){this.form['Samp2'].style.visibility='visible'}
              if (this.value=='Cellmark'){this.form['Samp2'].disabled=false}
              if (this.value=='Cellmark'){this.form['Samp3'].style.visibility='hidden'}
              if (this.value=='Cellmark'){this.form['Samp3'].disabled=true}
              if (this.value=='Cellmark'){this.form['Samp4'].style.visibility='hidden'}
              if (this.value=='Cellmark'){this.form['Samp4'].disabled=true}
              if (this.value=='Cellmark'){this.form['SegmCol1'].style.visibility='visible'}
              if (this.value=='Cellmark'){this.form['SegmCol1'].disabled=false}
              if (this.value=='DNA Legal'){this.form['Samp1'].style.visibility='hidden'}
              if (this.value=='DNA Legal'){this.form['Samp1'].disabled=true}
              if (this.value=='DNA Legal'){this.form['Samp2'].style.visibility='hidden'}
              if (this.value=='DNA Legal'){this.form['Samp2'].disabled=true}
              if (this.value=='DNA Legal'){this.form['Samp3'].style.visibility='visible'}
              if (this.value=='DNA Legal'){this.form['Samp3'].disabled=false}
              if (this.value=='DNA Legal'){this.form['Samp4'].style.visibility='hidden'}
              if (this.value=='DNA Legal'){this.form['Samp4'].disabled=true}
              if (this.value=='DNA Legal'){this.form['SegmCol1'].style.visibility='visible'}
              if (this.value=='DNA Legal'){this.form['SegmCol1'].disabled=false}
              if (this.value=='The Doctors Lab'){this.form['Samp1'].style.visibility='hidden'}
              if (this.value=='The Doctors Lab'){this.form['Samp1'].disabled=true}
              if (this.value=='The Doctors Lab'){this.form['Samp2'].style.visibility='hidden'}
              if (this.value=='The Doctors Lab'){this.form['Samp2'].disabled=true}
              if (this.value=='The Doctors Lab'){this.form['Samp3'].style.visibility='hidden'}
              if (this.value=='The Doctors Lab'){this.form['Samp3'].disabled=true}
              if (this.value=='The Doctors Lab'){this.form['Samp4'].style.visibility='visible'}
              if (this.value=='The Doctors Lab'){this.form['Samp4'].disabled=false}
              if (this.value=='The Doctors Lab'){this.form['SegmCol1'].style.visibility='visible'}
              if (this.value=='The Doctors Lab'){this.form['SegmCol1'].disabled=false}
              if (this.value=='Lab'){this.form['Samp1'].style.visibility='hidden'}
              if (this.value=='Lab'){this.form['Samp1'].disabled=true}
              if (this.value=='Lab'){this.form['Samp2'].style.visibility='hidden'}
              if (this.value=='Lab'){this.form['Samp2'].disabled=true}
              if (this.value=='Lab'){this.form['Samp3'].style.visibility='hidden'}
              if (this.value=='Lab'){this.form['Samp3'].disabled=true}
              if (this.value=='Lab'){this.form['Samp4'].style.visibility='hidden'}
              if (this.value=='Lab'){this.form['Samp4'].disabled=true}
              if (this.value=='Lab'){this.form['SegmCol1'].style.visibility='hidden'}
              if (this.value=='Lab'){this.form['SegmCol1'].disabled=true};">
                <option selected>Lab</option>
                <option value="Alpha Bio Labs">Alpha Bio Labs</option>
                <option value="Cellmark">Cellmark</option>
                <option value="DNA Legal">DNA Legal</option>
                <option value="The Doctors Lab">The Doctors Lab</option>
              </select>

将保存到数据库的选择

<option selected >Select Sample Type</option>
                <?php
$connection = mysqli_connect("", "", "", "");

$results = mysqli_query($connection, "SELECT SampleType, LabFee, LabFeeExtra FROM `sampletypes` WHERE Lab = 'Alpha Bio Labs'");

mysqli_close($connection); 
foreach($results as $user): ?>
                <option value="<?= $user['SampleType']; ?>">
                <?= $user['SampleType']; ?>
                </option>
                <?php endforeach; ?>
              </select>

php编码保存到数据库

$LaborDept = $_POST['Lab1'];
$SampleType1 = $_POST['Samp1'];
$SampleType1 = $_POST['Samp2'];
$SampleType1 = $_POST['Samp3'];
$SampleType1 = $_POST['Samp4'];
$Segmented1 = $_POST['SegmCol1'];
$LaborDept2 = $_POST['Lab2'];
$SampleType2 = $_POST['Samp5'];
$SampleType2 = $_POST['Samp6'];
$SampleType2 = $_POST['Samp7'];
$SampleType2 = $_POST['Samp8'];
$Segmented2 = $_POST['SegmCol2'];
$LaborDept3 = $_POST['Lab3'];
$SampleType3 = $_POST['Samp9'];
$SampleType3 = $_POST['Samp10'];
$SampleType3 = $_POST['Samp11'];
$SampleType3 = $_POST['Samp12'];
$Segmented3 = $_POST['SegmCol3'];
$LaborDept4 = $_POST['Lab4'];
$SampleType4 = $_POST['Samp13'];
$SampleType4 = $_POST['Samp14'];
$SampleType4 = $_POST['Samp15'];
$SampleType4 = $_POST['Samp16'];
$SegmentedCollection = $_POST['SegmCol'];
$Decleration = $_POST['Decl'];

mysqli_query($connection, "INSERT INTO `collectsamp`(`SampleID`, `LaborDept`, `NumberofSamples`, `SampleType1`, `Segmented1`, `LaborDept2`, `SampleType2`, `Segmented2`, `LaborDept3`, `SampleType3`, `Segmented3`, `LaborDept4`, `SampleType4`, `SegmentedCollection`, `Decleration`) VALUES ('$LabID', '$LaborDept', '$NumberofSamples', '$SampleType1', '$Segmented1', '$LaborDept2', '$SampleType2', '$Segmented2', '$LaborDept3', '$SampleType3', '$Segmented3', '$LaborDept4', '$SampleType4', '$SegmentedCollection', '$Decleration')");

任何帮助都将不胜感激

brccelvz

brccelvz1#

我修改了组合框并调整了编码以匹配下面的代码片段;

$SampleType4 = $_POST['Samp13'] . " " . $_POST['Samp14'] . " " . $_POST['Samp15'] . " " . $_POST['Samp16'];

相关问题