<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>
我想使用下拉列表中的选项提交表单。但表格没有提交。请帮帮我
答案 0 :(得分:0)
您缺少几个要关闭的标签:
</table>
</form>
你应该在下拉变化时绑定和事件处理程序。
$(document).ready(function(){
$("#branch").change(function(){
$("form[name=frm]").submit();
});
});
答案 1 :(得分:0)
缺少标签。
</table>
</form>
只需添加以下代码。
<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>