一連の div style="display:none;" があります そして、各divにjquery show hideを使用しています。
div の 1 つの中に選択メニューがあり、フォーム自体を $_SERVER['PHP_SELF'] に送信したいと考えています。フォームを送信しても正しい現在の div に留まるにはどうすればよいですか。
前もって感謝します。
<div style="display:none;">
<form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='post' name='form_filter' >
<select id="employee_user" name="employee_user" onchange="this.form.submit();">
<option value="">Select Staff</option>
<?php // $Id: emails.php, 27/06/2011 mbrennand
$users_in_department = mysql_query('SELECT DISTINCT(employee) FROM holiday_entitlement_academic WHERE line_manager = \'' . $username. '\'');
$users_in_department2 = mysql_query('SELECT DISTINCT(employee) FROM holiday_entitlement_business WHERE line_manager = \''.$username.'\'');
while($user_in_dept = mysql_fetch_array($users_in_department)) {
echo '<option value="'.$user_in_dept['employee'].'">'.$user_in_dept['employee'].'</option>';
}
while($user_in_dept2 = mysql_fetch_array($users_in_department2)) {
echo '<option value="'.$user_in_dept2['employee'].'">'.$user_in_dept2['employee'].'</option>';
}
?>
</select>
</form>
</div>
<div style="display:none;">
</div>
<div style="display:none;">
</div>
<div style="display:none;">
</div>
編集....コードが変更されました
<script type="text/javascript">
$('#employee_user').on('change', function(){
$.post('SELF', $('form input,form select').serializeArray(), function(data){
// Form has submitted
});
});
</script>
<div style="float:right;">
<form action='' method='post' name='form_filter' >
<select id="employee_user" name="employee_user">
<option value="">Select Staff</option>
<?php // $Id: emails.php, 27/06/2011 mbrennand
$users_in_department = mysql_query('SELECT DISTINCT(employee) FROM holiday_entitlement_academic WHERE line_manager = \'' . $username. '\'');
$users_in_department2 = mysql_query('SELECT DISTINCT(employee) FROM holiday_entitlement_business WHERE line_manager = \''.$username.'\'');
while($user_in_dept = mysql_fetch_array($users_in_department)) {
echo '<option value="'.$user_in_dept['employee'].'">'.$user_in_dept['employee'].'</option>';
}
while($user_in_dept2 = mysql_fetch_array($users_in_department2)) {
echo '<option value="'.$user_in_dept2['employee'].'">'.$user_in_dept2['employee'].'</option>';
}
?>
</select>
</form>
</div>
<h2>STAFF HOLIDAY LEAVE</h2>
<br/>
<?php
$username_indept = $_POST["employee_user"];
$is_academic_result = mysql_query('SELECT * FROM holiday_entitlement_academic WHERE employee = \'' . $username_indept . '\'');
$is_business_result = mysql_query('SELECT * FROM holiday_entitlement_business WHERE employee = \'' . $username_indept . '\'');
if($is_academic = mysql_fetch_array($is_academic_result)) {
switch($is_academic['units']) {
case 'days':
include_once('admin_academic_days.php');
break;
case 'hours':
include_once('admin_academic_hours.php');
break;
default:
break;
}
} else if ($is_business = mysql_fetch_array($is_business_result)) {
switch($is_business['units']) {
case 'days':
include_once('admin_business_days.php');
break;
case 'hours':
include_once('admin_business_hours.php');
break;
default:
break;
}
}
else {
include_once('no_record.php');
}
?>