Solved

Dropdown list

Posted on 2014-11-12
4
200 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 7

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
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…

803 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