I am trying to get the onchange event dropdown in jquery. When selecting a date from the drop-down list, another text field should be invisible, and the date text field should be visible. And when choosing a status, other text fields should be invisible, and the status of the drop-down list should be visible. This is not happening. Look at my code, what am I doing wrong. Your help means a lot.
_Layout.cshtml
<head>
<script type="text/javascript">
$(function () {
$('#categorie').on('change', function () {
if ($(this).val() == "Date") {
$('#keyword').hide();
$('#txtcalendar').show();
} else if ($(this).val() == "Status"){
$('#keyword').hide();
$('#txtcalendar ').hide();
$('#tmstatus ').show();
}
.
.
.
});
});
</script>
</head>
Index.cshtml
@Html.DropDownList("categorie", new SelectList(new[]
{
"All", "Id", "Status",
"Vendor", "Date"
}) as SelectList)
<p> Keyword: @Html.TextBox("keyword") <input id="Submit" type="submit" value="Search" /> </p>
<p>Calendar @Html.TextBox("txtcalendar", new {}, new { @class = "myclass", style = "display:none;" })</p>
@Html.DropDownList("tmstatus", new SelectList(new[]
{
"Success", "Pending", "Error",
}) as SelectList)
source
share