波紋顯示代碼做這些事 當我從選擇列表中選擇Scholership程序class =「mystaff_hide mystaff_opt1」的div元素將顯示 然後我選擇Family Income now div將顯示class =「mystaff_hide mystaff_opt2」。現在都在我的窗戶上了。 直到這個代碼工作正常想要顯示錶格提交後選定的div也
我要的是遞交的表格後,我想他們兩個都必須有我的窗戶
<div class="row">
<div class="col-md-6 col-sm-6 pull-left">
<div class="form-group">
<legend>Options to Search</legend>
<select class="form-control firstdropdown" name="sel_options" id="mystuff">
<option>Select Options</option>
<option value="opt1">Scholership Programs</option>
<option value="opt2">Family Income</option>
</select>
</div>
</div>
</div>
<div class="col-md-6 col-sm-6 mystaff_hide mystaff_opt1">
<div class="form-group">
<label for="LS_name">Scholarship</label>
<select class="form-control" name="LS_name[]" id="LS_name" multiple="multiple">
<option value="opt1">Scholership1</option>
<option value="opt2">Scholership2</option>
</select>
</div>
</div>
<div class="col-md-6 col-sm-6 mystaff_hide mystaff_opt2">
<div class="form-group">
<label for="Family Income">Family Income</label>
<select multiple class="form-control" name="FamilyIncome[]" id="FamilyIncome">
<option value="opt1">Family Income1</option>
<option value="opt2">Family Income2</option>
</select>
</div>
</div>
這是我的腳本
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/multi-select/0.9.12/js/jquery.multi-select.min.js"></script>
<script>
$(document).ready(function() {
$('.mystaff_hide').addClass('collapse');
$('#mystuff').change(function(){
var selector = '.mystaff_' + $(this).val();
$(selector).collapse('show');
});
});
</script>
經過很多搜索我得到這個代碼,這是隻顯示最近有關選定的選項的div
<?php if(isset($_POST['sel_options']) &&
!empty(isset($_POST['sel_options']))){
?>
<script>
var selected_option = "<?php echo $_POST['sel_options']; ?>";
var selector = '.mystaff_' + selected_option;
//show only element connected to selected option
$(selector).collapse('show');
</script>
<?php } ?>
你使用Ajax提交表單? –
不,提交後我指向相同的頁面 – mithunreddy
更好的情況下使用['Ajax']嘗試(https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad = RJA&uact = 8&VED = 0ahUKEwiAzM2Qq6HUAhXIuY8KHbV7AjYQFggqMAA&URL = HTTP%3A%2F%2Fapi.jquery.com%2Fjquery.ajax%2F&USG = AFQjCNET1WrVqP-BPFBEQY1R7V6crOtd1w&SIG2 = JP5YWkZ5Mr-WpBASz2YTbg) – prasanth