Reputation: 3105
I want to make a school management system. So I am trying to choose class from menu after then the selected class student id will be displayed with a marks input field.
dropdown menu
Class 6,
Class 7,
Class 8
Inputs
form id=6
student id:1
input type="marks"
student id:2
input type="marks"
similarly
form id=7
student id:1
input type="marks"
student id:2
input type="marks"
When I will choose class 6 then form id=6 will be display. Is it possible ???
Upvotes: 0
Views: 86
Reputation: 1043
Demo: Fiddle
Example HTML:
<select id="class_num">
<option val=""></option>
<option val="6">6</option>
<option val="7">7</option>
<option val="8">8</option>
</select>
<form id="6">
<input type="text" value="class 6"/>
</form>
<form id="7">
<input type="text" value="class 7"/>
</form>
<form id="8">
<input type="text" value="class 8"/>
</form>
Jquery:
$("form").hide();
$("#class_num").change(function(){
$("#"+$(this).val()).show();
});
Upvotes: 1
Reputation: 715
Consider your Dropdown menu id was "ClassName"
** Jquery **
$(function(){
$('form').hide(); // hide all form
$('#ClassName').change(function(){
$('form').hide();
$('form[id="'+$(this).val()+'"]').show();
});
});
Upvotes: 0