Dropdown list

Posted on 2014-11-12
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 19

Accepted Solution

Rikin Shah earned 2000 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

Setting up LaraDock for Laravel

Learn how to set up LaraDock in a Laravel project - LaraDock gives us an easy way to run a Laravel application using Docker in a single command.

Question has a verified solution.

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

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
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…
Suggested Courses

770 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