0
I have the following scenario: in a form
I have a field called Carga-Horaria, which is a Dropdownlist with a list of hourly loads. In this drop an option called another. When selected the option "Other" opens a new field to be typed this new workload.
I managed to do this normally with Javascript in my form
.
The point is, I’d like it to be saved in the bank, rather than having a column called, "Other Load-Time," I’d like to save this data in the column Carga-Horaria
existing.
<div class="form-group">
@Html.LabelFor(model => model.Nr_CHoraria, "Carga Horaria Semanal", new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model => model.Nr_CHoraria, new List<SelectListItem>
{
new SelectListItem() {Text = "12", Value="12"},
new SelectListItem() {Text = "20", Value="20"},
new SelectListItem() {Text = "24", Value="24"},
new SelectListItem() {Text = "30", Value="30"},
new SelectListItem() {Text = "36", Value="36"},
new SelectListItem() {Text = "40", Value="40"},
new SelectListItem() {Text = "44", Value="44"},
new SelectListItem() {Text = "Outra", Value="0"}
}, new { @class = "form-control", @id = "ch" })
@Html.ValidationMessageFor(model => model.Nr_CHoraria)
</div>
</div>
<div class="form-group" style="display:none" id="div_dch">
@Html.LabelFor(model => model.Nr_CHoraria, "Digite a Carga Horaria", new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextBoxFor(model => model.Nr_CHoraria, new { @class = "chs", @id = "dch" })
@Html.ValidationMessageFor(model => model.Nr_CHoraria)
</div>
</div>
<script type="text/javascript">
$(function () {
$('#ch').change(function () {
var value = $(this).val();
if (value == '0') {
$('#div_dch').show();
} else {
$('#div_dch').hide();
}
});
});
</script>