I have the following scenario: In a form
I have a field called Load-Time , which is a Dropdownlist with a list of time loads. In this drop an option called another. When the "Other" option is selected a new field is opened to enter this new workload.
I was able to do this normally with JavaScript in my form
.
The question is, I would like that when it is saved in the database, instead of having a column called, "Another Load-Time", I would like to save this data in the existing Carga-Horaria
column.
<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>