创建表格并显示所选字段

时间:2015-03-30 09:41:41

标签: javascript php html mysqli phpmyadmin

我填写了表格,并输入了车轴数(黑圈)。然后表单将我发送到此页面:

Form added

在这种形式中,我输入了12个轴,它在这里显示出来。 现在在黑圈下你会看到文本框。忽略那些。但在它们下面你会看到复选框。 现在我想要的是以下内容:

当我选择其中的2个,然后按:制作Boogie。我希望它创建一个表,并显示如下内容:

example

现在,当我按下Make Boogie时。我想要那两个选项框(或者更多取决于您选择的)灰显。所以我不能再选择它们了。 现在,当我按下接下来的2或3个车轴时,选择:制作Boogie。我希望表格能够扩展并显示该信息。完成后,选择选项会变灰。

我的代码(如果需要):

<div id="center">
<?php
    //Train is send here//
    $add_train = $database->train_add();
?>
    Train: <?php echo $_POST['train_name']; ?>
    <!--Here we make the number of fields based on the number of axles-->
    <div id="axle_bogie_border"><br /> <br />
    <!--The show axles are the number of checkboxes (Filled in by a user)-->
        <table>
            <div id="show_axles">
                <tr>
                    <?php
                        $_POST['number_of_axles'];
                            if(isset($_POST['number_of_axles'])){
                            for($i=0; $i<$_POST['number_of_axles']; $i++){
                                echo "<td>" . "<div id='axle_figure'>" . $i . "</div>" . "</td>";
                            }   
                        }
                    ?>
                </tr>               
            </div>


            <div id="distances">
                <tr>
                    <?php
                        $_POST['number_of_axles'];
                            if(isset($_POST['number_of_axles'])){
                            for($i=0; $i<$_POST['number_of_axles']; $i++){
                                echo "<td>" . "<input type='text' placeholder='Distance $i' id='field' name='distance[$i]'>" . "</td>";
                            }
                        }
                    ?>
                </tr>
            </div>


            <div id="checkboxes">
                <tr>
                    <?php
                        $_POST['number_of_axles'];
                            if(isset($_POST['number_of_axles'])){
                            for($i=0; $i<$_POST['number_of_axles']; $i++){
                                echo "<td>" . "<input type='checkbox' name='box[$i]'>" . "</td>";
                            }
                        }
                    ?>
                </tr>
            </div>
        </table>


            <!--De onClick function is nog een test (zie Script bij lijn 77)-->
            <button onclick="myFunction();" id="add_train_button2">Refresh</button>
            <button onclick="myFunction('testing');" id="add_train_button3">Make Boogie</button>
            <a href="index.php" id="return_to_home">Back to home screen!</a><br /><br />
            <p id="refresh_button"></p>

            <br /><br />
            <div id="button_explanation"><b>Refresh:</b> show train model after distances have been added (Axles get in place).<br />
            <b>Make Boogie:</b> after you selected the Nr. of wheels that contain 1 boogie you press the button<br />
            after you have done that, a table will show up with the Boog Nr. and the axle Nrs. of that boogie</div>
    </div>
</div>
<!--Dit script is een test-->
<script>
function myFunction() {
    document.getElementById('refresh_button').innerHTML = "Hello World";
}
</script>

$add_train = $database->train_add();来自此页面之前的表单。 (它从插入的火车上获得了车轴的数量。)

0 个答案:

没有答案