Link to home
Start Free TrialLog in
Avatar of lulu50
lulu50Flag for United States of America

asked on

Dropdown list

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

ASKER CERTIFIED SOLUTION
Avatar of Rikin Shah
Rikin Shah
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

Avatar of lulu50

ASKER

Rikin,

It works!!!!!!

Great!!!!!!

Thank you for your help!!!!!!
Avatar of lulu50

ASKER

Thank you