I have this javascript code
$('select[name="fselect"]').on('change', function() {
if ($(this).val() == "add") {
$('.add').show();
} else {
$('.blank').show();
$('.add').hide();
}
});
$('select[name="selection"]').on('change', function() {
if ($(this).val() == "project") {
$('.project').show();
$('.gallery').hide();
$('.event').hide();
$('.vikinglaw').hide();
$('.btn-project').show();
} else if ($(this).val() == "galleries") {
$('.gallery').show();
$('.project').hide();
$('.event').hide();
$('.vikinglaw').hide();
$('.btn-gallery').show();
} else if ($(this).val() == "event") {
$('.event').show();
$('.gallery').hide();
$('.project').hide();
$('.vikinglaw').hide();
$('.btn-event').show();
} else if ($(this).val() == "vikinglaw") {
$('.vikinglaw').show();
$('.event').hide();
$('.gallery').hide();
$('.project').hide();
$('.btn-vikinglaw').show();
} else {
$('.blank').show();
$('.project').hide();
$('.gallery').hide();
$('.event').hide();
$('.vikinglaw').hide();
$('.btn-vikinglaw').hide();
$('.btn-event').hide();
$('.btn-gallery').hide();
$('.btn-project').hide();
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="row">
<div class="col-md-12">
<label for="sel1">What action do you want?</label>
<select class="form-control" id="fselect" name="fselect">
<option name="nocontent" id="nocontent" value="nocontent">Please select action</option>
<option name="add" id="add" value="add">ADD</option>
<option name="edup" id="edup" value="edup">EDIT/UPDATE</option>
<option name="delete" id="delete" value="delete">DELETE</option>
</select>
</div>
</div>
<div class="add">
<div class="row">
<div class="col-md-12">
<label for="sel1">What page do you want your article to be posted</label>
<select class="form-control" id="selection" name="selection">
<option name="nocontent" id="nocontent" value="nocontent">Please select page</option>
<option name="project" id="project" value="project">Project</option>
<option name="gallery" id="gallery" value="galleries">Gallery</option>
<option name="event" id="event" value="event">Event</option>
<option name="vikinglaw" id="vikinglaw" value="vikinglaw">Viking Law</option>
</select>
</div>
</div>
</div>
What I am trying to do here is that I want to hide first the
$('select[name="selection"]').on('change',function(){
so that if i click
$('select[name="fselect"]').on('change',function(){
if($(this).val() == "add"){
$('.add').show();
}
the $('select[name="selection"]').on('change',function(){ will show.
Sorry if you don't understand very well english is not my native . I've been doing this for hours but i can't figure out how i can do it. Actually it's already working but i first need to click the add button before it works.
Here's an image so that you can fully understand me

As you can see on the image
On the "What action do you want" on the first load the "What page do you want your article to be posted" must be hide . But the problem is that it's not hiding
$('select[name="selection"]').on('change',function(){- You can assign the handler in the click if you wantswitchinstead ofif else if