Best idea is javascript.
I'm guessing that your using jQuery, as the form looks bootstrap-ish.
Try this,
<html>
<head>
<title>test</title>
<script src="jquery-1.12.0.min.js"></script>
<script>
$(function() {
// run on change for the selectbox
$( "#frm_duration" ).change(function() {
updateDurationDivs();
});
// handle the updating of the duration divs
function updateDurationDivs() {
// hide all form-duration-divs
$('.form-duration-div').hide();
var divKey = $( "#frm_duration option:selected" ).val();
$('#divFrm'+divKey).show();
}
// run at load, for the currently selected div to show up
updateDurationDivs();
});
</script>
</head>
<body>
<form>
<div class="form-group">
<label class="col-md-3 control-label">Duration </label>
<div class="col-md-9">
<select class="form-control" id="frm_duration">
<option value="Monthly">Monthly</option>
<option value="Quarterly">Quarterly</option>
<option value="HalfYearly">Half Yearly</option>
<option value="Yearly">Yearly</option>
</select>
</div>
</div>
<div id="divFrmMonthly" class="form-group form-duration-div" style="display:none">
<label class="col-md-3 control-label">Monthly</label>
<div class="col-md-9">
<input type="text" class="form-control" placeholder="Monthly" > </div>
</div>
<div id="divFrmQuarterly" class="form-group form-duration-div" style="display:none">
<label class="col-md-3 control-label">Quarterly</label>
<div class="col-md-9">
<input type="text" class="form-control " placeholder="Quarterly" > </div>
</div>
<div id="divFrmHalfYearly" class="form-group form-duration-div" style="display:none">
<label class="col-md-3 control-label">Half Yearly</label>
<div class="col-md-9">
<input type="text" class="form-control" placeholder="Half Yearly" > </div>
</div>
<div id="divFrmYearly" class="form-group form-duration-div" style="display:none">
<label class="col-md-3 control-label">Yearly</label>
<div class="col-md-9">
<input type="text" class="form-control" placeholder="Yearly" > </div>
</div>
</form>
</body>
</html>
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community