Reputation: 429
Hi currently i have a problem with my Onclick because it wont reload on my page This is what i have.
<div id="vpanel">
<div>
<form method="post" action="enrollalpha.php">
<label>View Panel</label>
<select name="Vpanel" onclick="return.this.form">
<option value="VS">Students</option>
<option value="VSc">Section</option>
<option value="VA">Adviser</option></select>
</form>
</div>
</div>
And will be used in this code on the same page.
<form method="post" action="">
<div id="tbody" class="scrollbar">
<?php
if(!empty($_POST['Vpanel'])){
$vview = $_POST['Vpanel'];
}else{
$vview = 'VS';
}
if($vview == 'VS'){
require_once 'vpanel_student.php';
}else if($vview == 'VSc'){
require_once 'vpanel_section.php';
}else if($vview == 'VA'){
require_once 'vpanel_adviser.php';
}else{
require_once 'vpanel_student.php';
}
?>
</div>
Would appreciate any help on what I'm doing wrong.
Upvotes: 0
Views: 2071
Reputation: 241
Replace onclick by onchange because you want to submit your form when your option selected change and not when you click on your select and use this.form.submit();
Or use this html :
<form id="form-vpanel" method="post" action="enrollalpha.php">
<label>View Panel</label>
<select id="vpanel" name="Vpanel">
<option value="VS">Students</option>
<option value="VSc">Section</option>
<option value="VA">Adviser</option>
</select>
</form>
With this JQuery :
$('#vpanel').change(function() {
$('#form-vpanel').submit();
});
Upvotes: 0
Reputation: 2561
replace you code with below line
<select name="Vpanel" onchange="this.form.submit();">
Upvotes: 2
Reputation: 39724
use this.form.submit()
and onchange()
:
<select name="Vpanel" onchange="this.form.submit();">
<option value="VS">Students</option>
<option value="VSc">Section</option>
<option value="VA">Adviser</option>
</select>
Upvotes: 3