Solved

Dropdown list

Posted on 2014-11-12
4
202 Views
Last Modified: 2014-11-12
Hi,

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>
            </select>

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>
            </select>

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)
		}
		else
		{
			$("#retired option").prop("selected",0)
		}
		return true;
	  }

Open in new window

0
Comment
Question by:lulu50
  • 2
4 Comments
 
LVL 19

Accepted Solution

by:
Rikin Shah earned 500 total points
ID: 40437237
Hi,

Try this-
$("#retired").val("1");
0
 
LVL 8

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

0
 

Author Comment

by:lulu50
ID: 40437243
Rikin,

It works!!!!!!

Great!!!!!!

Thank you for your help!!!!!!
0
 

Author Closing Comment

by:lulu50
ID: 40437245
Thank you
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to dynamically set the form action using jQuery.
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…

860 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