Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/270.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 使用下拉列表中的选项提交表单_Javascript_Php_Jquery_Html_Forms - Fatal编程技术网

Javascript 使用下拉列表中的选项提交表单

Javascript 使用下拉列表中的选项提交表单,javascript,php,jquery,html,forms,Javascript,Php,Jquery,Html,Forms,我想使用下拉列表中的一个选项重新提交表单。但是表格没有被提交。请帮我解决问题您缺少几个要关闭的标记: <html> <head> <title> </title> <script type="text/javascript"> var datefield=document.createElement("input"); datefield.setAttribute("type", "date"); if (d

我想使用下拉列表中的一个选项重新提交表单。但是表格没有被提交。请帮我解决问题

您缺少几个要关闭的标记:

<html>
<head>
<title>         </title>
<script type="text/javascript">
  var datefield=document.createElement("input");
  datefield.setAttribute("type", "date");
  if (datefield.type!="date"){ //if browser doesn't support input type="date", load   
files for jQuery UI Date Picker
    document.write('<link type="text/css" href="scripts/jquery-ui.css" rel="stylesheet" 
/>\n');
    document.write('<script src="scripts/jquery.min.js"><\/script>\n');
    document.write('<script src="scripts/jquery-ui.min.js"><\/script>\n');
           }
</script>

   <script>
     if (datefield.type!="date"){ //if browser doesn't support input type="date",   
    initialize date picker widget:
    jQuery(function($){ //on document.ready
        $('#date').datepicker();
    });
    }
    </script>
    <style type="text/css">
    body{
    margin-left: 10%;
    margin-right: 10%;

    font-family: sans-serif;
    }
    </style>
    </head>
    <body>
    <h1 align="center">Date Sheet Feed </h1>
    <form name="frm" method="post" action='<?php echo $_SERVER['PHP_SELF']; ?>'>
    <table width="50%" border="1" cellpadding="3" cellspacing="3" align="center">
    <?php 
    $value1=array();
    $select_query="SELECT Distinct branch FROM department";
    $result=mysqli_query($dbcon,$select_query);
     if(!$result) die("Fail".mysqli_error($dbcon));

    while($row=mysqli_fetch_array($result))
    {
        $value1[]=$row['branch'];
    }

    ?>
    <tr><td>Branch<td><select name="branch" id="branch"  onchange="document.frm.submit();">
                 <option >Select Branch</option>
                   <?php  
                         foreach($value1 as $gets)
                         {
                        ?>
                           <option value='<?php echo $gets;?>' <?php   
    if(true===isset($_POST['branch']))
                          {
                            print($gets==$_POST['branch'] ? ' selected="selected"' :   
    '');
                     }     ?> > <?php echo $gets; ?></option> 

                      <?php 
                      }
               ?>
            </select></td></tr>
缺少标签

$(document).ready(function(){
    $("#branch").change(function(){
        $("form[name=frm]").submit();
    });
});
只需添加以下代码

 </table>
</form>
例如:

<select onchange="this.form.submit()">
    ...
</select>

我查看了您的代码,但没有找到结束标记。您需要附加jquery更改功能,以在下拉值上提交表单。更改显示在主代码中
<select onchange="this.form.submit()">
    ...
</select>
<!DOCTYPE html>
<html>
  <head>
  </head>
  <body>
    <form action="index.html" onsubmit="alert('Form Submitted');" method="post">
    <select name="data" onchange="this.form.submit()">
      <option value="orange">orange</option>
      <option value="yellow">yellow</option>
      <option value="blue">blue</option>
      <option value="pink">pink</option>
      <option value="lightdark">lightdark</option>
    </select>
    </form>
  </body>
</html>