Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php、mysql、jquery、表单元素链选择_Php_Jquery_Html_Mysql_Chaining - Fatal编程技术网

php、mysql、jquery、表单元素链选择

php、mysql、jquery、表单元素链选择,php,jquery,html,mysql,chaining,Php,Jquery,Html,Mysql,Chaining,我在使用链式(表单元素)选择时遇到问题。 我似乎无法使用jquery触发第二个选择选项,该选项将使用$examplevar作为过滤器来填充,该过滤器由第一个下拉列表中选择的选项生成 <form name="vlan" action="" method="post"> <div class="row"> <div class="col-md-6"> <?php $con_string=

我在使用链式(表单元素)选择时遇到问题。 我似乎无法使用jquery触发第二个选择选项,该选项将使用$examplevar作为过滤器来填充,该过滤器由第一个下拉列表中选择的选项生成

    <form name="vlan" action="" method="post"> 
      <div class="row">
        <div class="col-md-6">
        <?php
        $con_string= "host=example port=xxxx dbname=example user=example password=example";
        $db_con = pg_connect($con_string);
        $dev = pg_query($db_con, "SELECT DISTINCT \"Type\" FROM \"End_Devices\"");

                            echo "  
                            <a class=\"current_page_item\">Location NASID:</a>
                            <input type=\"text\" name=\"nasid\" />      
                            <br>
                            <a class=\"current_page_item\">Device Name:</a>
                            <input type=\"text\" name=\"name\" />   
                            <br>
                            <input type=\"hidden\" name=\"dvtype\"/>
                            <a class=\"current_page_item\">Device Type:</a> 
                            <select name=\"slType\" id=\"slType\">";

                            while ($device = pg_fetch_array($dev))
                            {
                                echo "<option id=\"" .$device['Type'].  "\">" .$device['Type']. "</option>";

                            }
                            echo "<script type=\"text/javascript\">

                                $(\"#slType\").chained(\"#slModel\");
                                $(\"#slType\").on(\"change\",function(){
                                    var slTypeID = $(this).val();
                                    $.post('inventoryTEST.php', {slTypeID:slTypeID}, function(data){
                                        $('#slModel').html(data);
                                    });
                                });

                            </script>";


                            echo "
                            </select>
                            <br>
                            <a class=\"current_page_item\">Device Model:</a>
                            <select  name=\"slModel\" id=\"slModel\" >";

                            if (isset($_POST['slTypeid']))
                            {
                                $selection = ($_POST(['slTypeid']));

                            }

                            $mod = pg_query($db_con, "SELECT \"Model\" FROM \"End_Devices\" WHERE \"Type\"=\"". $selection . "\"");
                            while ($model = pg_fetch_array($mod))
                            {
                                echo $_POST[type];
                                echo "<option id=\"" .$model['Model'].  "\">" .$model['Model']. "</option>";
                            }
                            echo "
                            </select>
                            <br>
                            <a class=\"current_page_item\">Physical Location:</a>
                            <input type=\"text\" name=\"location\" />
                            <br>
                            <a class=\"current_page_item\">Serial:</a>
                            <input type=\"text\" name=\"serial\" /> 
                            <br>
                            <a class=\"current_page_item\">IP Address:</a>
                            <input type=\"text\" name=\"ip\" />
                            <br>
                            <a class=\"current_page_item\">MAC:</a>
                            <input type=\"text\" name=\"mac\" />    
                            <br>
                            <a class=\"current_page_item\">SSID:</a>
                            <input type=\"text\" name=\"ssid\" />
                            <br>
                            <a class=\"current_page_item\">WLAN Area:</a>
                            <input type=\"text\" name=\"wlan\" />   
                            <br>
                            <br>
                            <br>
                        ";
                        ?>
                            <!--SUBMIT INPUT-->
                            <input type="submit" value="Save" name="submit" />
                        </div>
                    </div>
                </form>


通过使用jquery和.ajax将所选的行内容.change with post传递到外部php,然后我将其用作过滤器并在填充第二个组合框时查询数据库,从而解决了这个问题