I’m pretty new to this stuff so bear with please.
I have a form that has a dynamic drop down list with MySql table results displayed as well as a static “Add New” choice. It defaults to “please select”
I’m using JS to make fields appear below the list when the user chooses “add new” but as always … issues.. *sigh
The JS code:
======================
function hide(obj)
{
obj1 = document.getElementById(obj);
obj1.style.visibility = ‘hidden’;
obj2 = document.getElementById(obj);
obj2.style.visibility = ‘hidden’;
obj3 = document.getElementById(obj);
obj3.style.visibility = ‘hidden’;
}
function show(obj)
{
obj1 = document.getElementById(obj);
obj1.style.visibility = ‘visible’;
obj2 = document.getElementById(obj);
obj2.style.visibility = ‘visible’;
obj3 = document.getElementById(obj);
obj3.style.visibility = ‘visible’;
}
function show_other2(optionValue)
{
if(optionValue==’add_new’){show(‘txt1’) & show(‘txt2’) & show(‘txt3’);} else{hide(‘txt1’) & hide(‘txt2’) & hide(‘txt3’);}
I have onChange=”show_other2(this.value) as the trigger on the drop down list menu. I have the ‘txt1’ etc inside Div tags encapsulating the fields I want to hide and show.
The code actually works well except for the first load of the page. The first load hides ‘txt1’ and thats it… the remaing two fields are shown.. but when the drop down list is used all the fields work great.. the three fields will appear on ‘add_new’ and disappear in unison when any other selection is made.
So.. any ideas? I don’t know much about JS.. other than it does great things. I came up the current code layout by fluke… I grabbed it from a site then adapted it. By the way.. if show_other2 doesn’t have the 2 the last two fields don’t work.
I’m a little perplexed at this stage..
Thanks in advance.. Eno