Solved

ASP.Net MVC 4 C# -- dropdown inFocus text ?

Posted on 2013-05-30
1
350 Views
Last Modified: 2013-07-02
How can I get the attached additional text to display when a dropdown is selected ?

The text is NOT in a database.
s001.jpg
0
Comment
Question by:finance_teacher
1 Comment
 
LVL 23

Accepted Solution

by:
Roopesh Reddy earned 500 total points
ID: 39253882
Hi,

You can do that using JavaScript. Check the below code -

 <select id="ddl">
        <option>N/A</option>
        <option>1</option>
        <option>2</option>
        <option>3</option>
        <option>4</option>
        <option>5</option>
    </select>
    <span id="msg"></span>

    <script type="text/javascript">
        window.addEventListener("change",OnChange,true);
        
        function OnChange() {
            var ddl = document.getElementById('ddl');
            switch (ddl.selectedIndex) {
                case 1:
                    document.getElementById("msg").innerHTML = "superficial or negligible damage";
                    break;
                case 2:
                    document.getElementById("msg").innerHTML = "Minor damage";
                    break;
                case 3:
                    document.getElementById("msg").innerHTML = "significant damage";
                    break;
                case 4:
                    document.getElementById("msg").innerHTML = "Repairable damage";
                    break;
                case 5:
                    document.getElementById("msg").innerHTML = "Non-Repairable damage";
                    break;
                default:
                    document.getElementById("msg").innerHTML = "";
                    break;
            }
           
        }
    </script>

Open in new window


Hope it helps u...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now