mercredi 11 novembre 2020

Autofill of data when dropdown content is selected and Checkbox activated with PHP

I'm trying to get this function in PHP: You select one field of the Dropdown neü "Kostenstelle". If you click on the Checkbox "PSP Element", an other number, which only matches the kind of number you selected, will also be inserted to the database. If you only selected the number in the dropdown menu without hitting the Checkbox, there will no other "PSP Element" number be inserted.

I dont really know how to get this function. I dont find something that fits with my needings and wanted to ask this here ...

My dropdown menu: ` Kostenstelle

                                <?php




                                        $sql4 = "SELECT kstnr, kostenstelle FROM kostenstelle";
                                        $result4 = $connection->query($sql4);

                                        if ($result4->num_rows > 0) {

                                        echo "<select name='kstnr'>";
                                        // output data of each row
                                        while($row = $result4->fetch_assoc()) {
                                        echo "<option value='" . $row['kstnr'] . "'>" . $row['kostenstelle'] . "</option>";
                                        }
                                        echo "</select>";
                                        }

                                 ?>
                                </div>`

The other Dropdown menu, which should be selected automatically (it dont have to be a dropdown menu):

<div class="form-group">
                        <select name="InvestPSPID">
                        <option value="">PSP-Element</option>
                        <option name="InvestPSPID" value="1">Z-T1D-100000096-07</option>
                        <option name="InvestPSPID" value="2">Z-T1D-100000096-04 </option>
                        <option name="InvestPSPID" value="3">Z-T1D-100000096-05</option>
                        <option name="InvestPSPID" value="4"> Z-T1D-100000096-03</option>
                        <option name="InvestPSPID" value="5">empty</option>
                        <option name="InvestPSPID" value="6">Z-T1D-100000096-08</option>
                        <option name="InvestPSPID" value="7">Z-T1D-100000096-06</option>
                        <option name="InvestPSPID" value="8">Z-T1D-100000106-01</option>
                        <option name="InvestPSPID" value="9">Z-T1D-100000107-01</option>
                        <option name="InvestPSPID" value="10">Z-T1D-100000107-02</option>
                        <option name="InvestPSPID" value="11">Z-T1D-100000107-03</option>
                        <option name="InvestPSPID" value="12">Z-T1D-100000099-02</option>
                        <option name="InvestPSPID" value="13">Z-T1D-100000109-11</option>
                        <option name="InvestPSPID" value="14">Z-T1D-100000109-12</option>
                        <option name="InvestPSPID" value="15">Z-T1D-100000109-13</option>
                        <option name="InvestPSPID" value="16">Z-T1D-100000109-07</option>
                        <option name="InvestPSPID" value="17">Z-T1D-100000109-08</option>
                        <option name="InvestPSPID" value="18">Z-T1D-100000109-09</option>
                        <option name="InvestPSPID" value="19">Z-T1D-100000109-10</option>
                        <option name="InvestPSPID" value="20">Z-T1D-100000109-03</option>
                        <option name="InvestPSPID" value="21">Z-T1D-100000109-04</option>
                        <option name="InvestPSPID" value="22">Z-T1D-100000110-06 </option>
                        <option name="InvestPSPID" value="23">Z-T1D-100000110-04</option>
                        <option name="InvestPSPID" value="24">Z-T1D-100000110-05</option>
                        <option name="InvestPSPID" value="25">Z-T1D-100000110-08</option>
                        <option name="InvestPSPID" value="26">Z-T1D-100000110-07</option>
                        <option name="InvestPSPID" value="27">Z-T1D-100000111-02</option>
                        <option name="InvestPSPID" value="28">Z-T1D-100000111-04</option>
                        <option name="InvestPSPID" value="29">Z-T1D-100000111-05</option>
                        <option name="InvestPSPID" value="30">Z-T1D-100000105-03</option>
                        <option name="InvestPSPID" value="31">empty</option>
                        <option name="InvestPSPID" value="32">empty</option>
                        <option name="InvestPSPID" value="33">empty</option>
                        <option name="InvestPSPID" value="34">empty</option>
                        <option name="InvestPSPID" value="35">empty</option>
                        </select>


                        </div>

My little Checkbox with no function yet:

 <div>

<input type="checkbox" name="Investnr" id="Investnr" ><label for="Element">PSP Element</label>

</div>

I am thankfull for every tipp :)




Aucun commentaire:

Enregistrer un commentaire