I've got a textbox that I only want to show if the value of Model.SelectedSubProcessID is -2.
<script>
$(function () {
$('#subProcessAdditionalDiv').hide();
});
</script>
<div id="modifyForm" class="incidentBox" style="justify-content: flex-start !important; width: auto !important; padding-left: 20px; text-align: left; align-items: flex-start !important;">
...
if (Model.SelectedSubProcessID == -2)
{
<script type="text/javascript">
$('#subProcessAdditionalDiv').show();
</script>
}
...
</div>
<br />
<div id="subProcessAdditionalDiv" style="display:flex; margin-bottom:10px">
@Html.LabelFor(m => m.SelectedSubProcessName, new { style = "margin-top: 2px" })<span> </span>
@Html.TextBoxFor(m => m.SelectedSubProcessName, new { style = "width:500px; margin-left: 120px" })<span> </span>
@Html.ValidationMessageFor(m => m.SelectedSubProcessName)
</div>
Even when the if statement is true the line $('#subProcessAdditionalDiv').show(); does not execute and the textbox remains hidden, why is this?