On select display another combo box not working for me???

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
cturner
Forum Contributor
Posts: 153
Joined: Sun Jul 16, 2006 3:03 am
Location: My computer

On select display another combo box not working for me???

Post by cturner »

Okay I give up. What I am trying to do is: when Company in the eligibilitytype combo box is selected it is meant to display select1 combo box. I have posted the code that I have been working with, below. Can someone please help me solve this problem? Thanks in advance.

Code: Select all

function dropdown1() {
    var srcElement = document.getElementById('select1');
	var a = document.getElementById('eligibilitytype');
    if(a == "Company") {
       srcElement.style.visibility = "visible";
    } else {
       srcElement.style.visibility = "hidden";
    }    
    }

Code: Select all

<select name="eligibilitytype" id="eligibilitytype" onchange="dropdown1();">

Code: Select all

<select name="select1" id="select1" style="visibility: hidden">
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

"a" won't be a string, but an object or undefined.
User avatar
cturner
Forum Contributor
Posts: 153
Joined: Sun Jul 16, 2006 3:03 am
Location: My computer

Post by cturner »

feyd wrote:"a" won't be a string, but an object or undefined.
Can you please show me how I solve that problem?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

cturner wrote:
feyd wrote:"a" won't be a string, but an object or undefined.
Can you please show me how I solve that problem?
You'll need to access it's properly and not the object itself

change

Code: Select all

document.getElementById('eligibilitytype')
to

Code: Select all

document.getElementById('eligibilitytype').value
Post Reply