Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/266.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
从javascript和php提交表单_Javascript_Php_Jquery - Fatal编程技术网

从javascript和php提交表单

从javascript和php提交表单,javascript,php,jquery,Javascript,Php,Jquery,我有两个输入元素,我使用JavaScript选择开始和结束日期: <form name="form" method="POST" action="accesari.php"> <p>FROM: <input type="text" id="min" name="min"> </p> <p>TO: <input type="text" id="max" name="max"> </p> <input type

我有两个输入元素,我使用JavaScript选择开始和结束日期:

<form name="form" method="POST" action="accesari.php">
<p>FROM:
<input type="text" id="min" name="min">
</p>
<p>TO:
<input type="text" id="max" name="max">
</p>
<input type="submit" name="submit"/>
</form>
  </head>
  <body>
  <script>
 $(document).ready(function() {
  $("#min").datepicker({
    dateFormat: 'd-mm-yy',
    onSelect: function(dateText, inst) {
      $("#min").text(dateText);
    }
  });
});
</script>
<script>
$(document).ready(function() {
  $("#max").datepicker({
    dateFormat: 'd-mm-yy',
    onSelect: function(dateText, inst) {
      $("#max").text(dateText);
    }
  });
});
 </script>
然后,在php中,我使用另一个表单从一个下拉列表中选择客户端,下拉列表中填充了SQL表中的值:

echo ('<form action="accesari.php" method="post">');
$sql=mysqli_query($aBD->con,"SELECT DISTINCT DenClient FROM $tabel WHERE DenClient!='xxxx'");
if(mysqli_num_rows($sql)){
$select= '<select name="select">';
$select.= '<option> </option>';
while($rs=mysqli_fetch_array($sql)){
$select.='<option>'.$rs['DenClient'].'</option>';
 }
}

$select.='</select>';
echo $select;
echo ('<input type="submit" name="submit"/>
</form>');

if ( isset( $_POST['submit'] ) ) {
    ////is submitted
$client = $_POST['select'];

   // //DO STUFF WITH DATA
}
我想一次提交所有内容。可能吗?
提前感谢,

请将所有内容放在同一页中:

$sql=mysqli_query($aBD->con,"SELECT DISTINCT DenClient FROM $tabel WHERE DenClient!='xxxx'");
if(mysqli_num_rows($sql)){
$select= '<select name="select">';
$select.= '<option> </option>';
while($rs=mysqli_fetch_array($sql)){
$select.='<option>'.$rs['DenClient'].'</option>';
 }
}

$select.='</select>';

if ( isset( $_POST['submit'] ) ) {
    ////is submitted
$client = $_POST['select'];

   // //DO STUFF WITH DATA
} ?>

<form name="form" method="POST" action="accesari.php">
<p>FROM:
<input type="text" id="min" name="min">
</p>
<p>TO:
<input type="text" id="max" name="max">
</p>
<? echo $select;?>
<input type="submit" name="submit"/>
</form>
</head>
 <body>
<script>
 $(document).ready(function() {
 $("#min").datepicker({
   dateFormat: 'd-mm-yy',
   onSelect: function(dateText, inst) {
  $("#min").text(dateText);
 }
 });
 });
</script>
<script>
$(document).ready(function() {
 $("#max").datepicker({
   dateFormat: 'd-mm-yy',
   onSelect: function(dateText, inst) {
    $("#max").text(dateText);
   }
 });
});
</script>

只需将所有内容放在同一页中:

$sql=mysqli_query($aBD->con,"SELECT DISTINCT DenClient FROM $tabel WHERE DenClient!='xxxx'");
if(mysqli_num_rows($sql)){
$select= '<select name="select">';
$select.= '<option> </option>';
while($rs=mysqli_fetch_array($sql)){
$select.='<option>'.$rs['DenClient'].'</option>';
 }
}

$select.='</select>';

if ( isset( $_POST['submit'] ) ) {
    ////is submitted
$client = $_POST['select'];

   // //DO STUFF WITH DATA
} ?>

<form name="form" method="POST" action="accesari.php">
<p>FROM:
<input type="text" id="min" name="min">
</p>
<p>TO:
<input type="text" id="max" name="max">
</p>
<? echo $select;?>
<input type="submit" name="submit"/>
</form>
</head>
 <body>
<script>
 $(document).ready(function() {
 $("#min").datepicker({
   dateFormat: 'd-mm-yy',
   onSelect: function(dateText, inst) {
  $("#min").text(dateText);
 }
 });
 });
</script>
<script>
$(document).ready(function() {
 $("#max").datepicker({
   dateFormat: 'd-mm-yy',
   onSelect: function(dateText, inst) {
    $("#max").text(dateText);
   }
 });
});
</script>

您可能需要将所有字段嵌入一个表单标记中,如下所示。 首先在文件顶部构建Select-in-PHP,甚至在打开HTML标记之前

        <?php
            $sql    = mysqli_query($aBD->con,"SELECT DISTINCT DenClient FROM $tabel WHERE DenClient!='xxxx'");
            if(mysqli_num_rows($sql)){
                $select= '<select name="select">';
                $select.= '<option> </option>';
                while($rs=mysqli_fetch_array($sql)){
                    $select.='<option>'.$rs['DenClient'].'</option>';
                }
            }
            $select.='</select>';

            // PROCESS YOUR FORM...
            if ( isset( $_POST['submit'] ) ) {
                ////is submitted
                $client = $_POST['select'];

                // //DO STUFF WITH DATA
            }

        ?>
        <html>
            <head>
                <script>
                    // NO NEED FOR 2 SCRIPT BLOCK... ONE SHOULD DO.
                    $(document).ready(function() {
                        $("#min").datepicker({
                            dateFormat: 'd-mm-yy',
                            onSelect: function(dateText, inst) {
                                $("#min").text(dateText);
                            }
                        });

                        $("#max").datepicker({
                            dateFormat: 'd-mm-yy',
                            onSelect: function(dateText, inst) {
                                $("#max").text(dateText);
                            }
                        });
                    });
                </script>
            </head>

            <body>
                <form name="form" method="POST" action="accesari.php">
                    <p>FROM:
                        <input type="text" id="min" name="min">
                    </p>
                    <p>TO:
                        <input type="text" id="max" name="max">
                    </p>
                    <!-- EMBED THE SELECT -->
                    <p>Select your option:
                        <?php echo $select; ?>
                    </p>
                    <input type="submit" name="submit"/>
                </form>
            </body>
        </html>

您可能需要将所有字段嵌入一个表单标记中,如下所示。 首先在文件顶部构建Select-in-PHP,甚至在打开HTML标记之前

        <?php
            $sql    = mysqli_query($aBD->con,"SELECT DISTINCT DenClient FROM $tabel WHERE DenClient!='xxxx'");
            if(mysqli_num_rows($sql)){
                $select= '<select name="select">';
                $select.= '<option> </option>';
                while($rs=mysqli_fetch_array($sql)){
                    $select.='<option>'.$rs['DenClient'].'</option>';
                }
            }
            $select.='</select>';

            // PROCESS YOUR FORM...
            if ( isset( $_POST['submit'] ) ) {
                ////is submitted
                $client = $_POST['select'];

                // //DO STUFF WITH DATA
            }

        ?>
        <html>
            <head>
                <script>
                    // NO NEED FOR 2 SCRIPT BLOCK... ONE SHOULD DO.
                    $(document).ready(function() {
                        $("#min").datepicker({
                            dateFormat: 'd-mm-yy',
                            onSelect: function(dateText, inst) {
                                $("#min").text(dateText);
                            }
                        });

                        $("#max").datepicker({
                            dateFormat: 'd-mm-yy',
                            onSelect: function(dateText, inst) {
                                $("#max").text(dateText);
                            }
                        });
                    });
                </script>
            </head>

            <body>
                <form name="form" method="POST" action="accesari.php">
                    <p>FROM:
                        <input type="text" id="min" name="min">
                    </p>
                    <p>TO:
                        <input type="text" id="max" name="max">
                    </p>
                    <!-- EMBED THE SELECT -->
                    <p>Select your option:
                        <?php echo $select; ?>
                    </p>
                    <input type="submit" name="submit"/>
                </form>
            </body>
        </html>
ajax:ajax: