I have the following drop down list on my page. I also have a onchange event if someone selects an item from the drop down list. I can see the item index in the onchange event:
@(Html.Kendo().DropDownList()
.Name("Awards")
.Label(label => label.Content("Please select Award type from the list. "))
.DataTextField("AwardCategory1")
.DataValueField("AwardId")
.OptionLabel("Select award")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetAwards", "Home");
});
})
.Events(e => e.Change("onChange"))
)
This is my onChange event:
<script>
function onChange(e) {
var dropdownlist = $("#Awards").data("kendoDropDownList");
var text = dropdownlist.text();
$(".award").text(text);
alert(text);
}
</script>
In the alert, I can see the selected item from the dropdown. I want to display some text on my web page based on the selected item so if text =="Award1" then I want to display
if (text =="Award1" )
<h3>"This is the award text for several people. Everyone will be given Award "A"></h3>
else if (text =="Award2")
<h3>"Test this award. Please make sure, you will be on time"</h3>
else if (text =="Award3")
and so on.
How can I show the h3 tag text on my web page based on the drop down list value. I can successfully capture the drop down list text value in JavaScript, but how can I display a certain text based on the selected item. I tried to put this line in my Javascript function:
$(".award").text(text);
so that I can capture this in tag like this:
<span class="award"></span>
with the above line, I can see the selected award, but I cannot display different text on my web page when a different item is selected. I dont need help with Telerik dropdown, I need help with javascript part.
any help is appreciated.