Solved

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

Posted on 2013-05-30
1
347 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

760 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

25 Experts available now in Live!

Get 1:1 Help Now