Dropdown list

Posted on 2014-11-12
Last Modified: 2014-11-12

I have two dropdown list

The first one is this:
 <select name="AppLifeCycle" size="1" id="AppLifeCycle" onChange="return ChangeStatus();">
            <option value="Core" selected>Core</option>
            <option value="Declining" >Declining</option>
            <option value="Emerging" >Emerging</option>
            <option value="Niche" >Niche</option>
            <option value="Phase-Out" >Phase-Out</option>
            <option value="Planned" >Planned</option>
            <option value="Retired" >Retired</option>

Open in new window

and the Second one is this:

 <select name="retired" size="1" id="retired">
                <option value="0" selected>No</option>
                <option value="1" >Yes</option>

Open in new window

What I want is when the user select the value "Retired" from AppLifeCycle list box,
it should automatically select the option "Yes" from the list box retired.

this is what I have so far that does not work.

function ChangeStatus() {
		 var RetiredFld = $("#AppLifeCycle").val();  
		  if ( RetiredFld == "Retired"){
			$("#retired option").prop("selected",1)
			$("#retired option").prop("selected",0)
		return true;

Open in new window

Question by:lulu50
  • 2
LVL 19

Accepted Solution

Rikin Shah earned 500 total points
ID: 40437237

Try this-

Expert Comment

by:Mukesh Yadav
ID: 40437242
Simply replace this one onChange="return ChangeStatus();" with code below

onChange="javascript:if(this.selectedIndex == 6){ document.getElementById('retired').selectedIndex = 1; }else{ document.getElementById('retired').selectedIndex = 0; }"

Open in new window


Author Comment

ID: 40437243

It works!!!!!!


Thank you for your help!!!!!!

Author Closing Comment

ID: 40437245
Thank you

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

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

23 Experts available now in Live!

Get 1:1 Help Now