Schammy
05-02-2003, 08:11 AM
I'm a novice and have 2 problems:
Background:
I have a combo box called "relation" with onchange="evalrelations()" . The combo box is populated with the values: son, father, uncle, grandson etc.
I also have several textboxes which have been set to visibility="hidden"
What I want is that when one selects a name from a combo box, then certain textboxes must become visible.
My Javascript code reads as follows:
function evalrelations()
{
if (document.familyform.relation.value="father")
{
document.familyform.textbox1.style.visibility='visible';
document.familyform.textbox2.style.visibility='visible';
}
if (document.familyform.relation.value="grandfather")
{
document.familyform.textbox3.style.visibility='visible';
document.familyform.textbox4.style.visibility='visible';
}
}
Problem 1:
I am not sure of the correct syntax when making a selection. For example, should my IF statement say TEXT='father', or VALUE='father', or SELECTED='father' etc.?
Problem 2:
If I select "father" then ALL 4 textboxes become visible instead of the 2 that I need. (Is this because 'grandfather' also contains the string 'father'?
Background:
I have a combo box called "relation" with onchange="evalrelations()" . The combo box is populated with the values: son, father, uncle, grandson etc.
I also have several textboxes which have been set to visibility="hidden"
What I want is that when one selects a name from a combo box, then certain textboxes must become visible.
My Javascript code reads as follows:
function evalrelations()
{
if (document.familyform.relation.value="father")
{
document.familyform.textbox1.style.visibility='visible';
document.familyform.textbox2.style.visibility='visible';
}
if (document.familyform.relation.value="grandfather")
{
document.familyform.textbox3.style.visibility='visible';
document.familyform.textbox4.style.visibility='visible';
}
}
Problem 1:
I am not sure of the correct syntax when making a selection. For example, should my IF statement say TEXT='father', or VALUE='father', or SELECTED='father' etc.?
Problem 2:
If I select "father" then ALL 4 textboxes become visible instead of the 2 that I need. (Is this because 'grandfather' also contains the string 'father'?