/    Sign up×
Community /Pin to ProfileBookmark

Need urgent help with a dropdown list Javascript

Hi There.

I’ve been reading this forum for quite sometime, but today is my first post, hope you guys can help.

Here is how the code works: (its like a phone directory)

-User first selects the dept.
-Once selected, a second drop down populates with the names of each person in that department.
-I want the contact info to show on the page once they select this last step.

I need for when the user selects this second options for a link to open inside a iFrame inside of the same html page.

Here is the code for the HTML doc:

[code=html]<body bgcolor=”#ffffff” text=”#000000″ link=”#0000ff” vlink=”#800080″ alink=”#ff0000″ onLoad=”fillCategory();”>

<FORM name=”drop_list” action=”yourpage.php” method=”POST” >

<SELECT NAME=”Department” onChange=”SelectSubCat();” >
<Option value=””>Select Department</option>
</SELECT>&nbsp;
<SELECT id=”SubCat” NAME=”SubCat”>
<Option value=””>SubCat</option>
</SELECT>
</form>[/code]

Here is the .js file code

[code=html]function fillCategory(){
// this function is used to fill the category list on load
addOption(document.drop_list.Department, “Executive-Management”, “Executive Management”);
addOption(document.drop_list.Department, “Marketing”, “Marketing”, “”);
addOption(document.drop_list.Department, “Annuities”, “Annuities”, “”);
addOption(document.drop_list.Department, “Underwriting/Case Management”, “Underwriting/Case Management”, “”);
addOption(document.drop_list.Department, “Human Resources”, “Human Resources”, “”);
addOption(document.drop_list.Department, “Commissions”, “Commissions”, “”);
addOption(document.drop_list.Department, “Policy Owner Services”, “Policy Owner Services”, “”);
addOption(document.drop_list.Department, “Information Technology”, “Information Technology”, “”);
addOption(document.drop_list.Department, “APS”, “APS”, “”);
}

function SelectSubCat(){
// ON selection of category this function will work

removeAllOptions(document.drop_list.SubCat);
addOption(document.drop_list.SubCat, “”, “SubCat”, “”);

if(document.drop_list.Department.value == ‘Executive-Management’){
addOption(document.drop_list.SubCat,”MartyGreenberg”, “Marty Greenberg – President”);
addOption(document.drop_list.SubCat,”LisaGreenberg “, “Lisa Greenberg – Vice President”);
addOption(document.drop_list.SubCat,”CraigBrown”, “Craig Brown – CFO”);
addOption(document.drop_list.SubCat,”RitaBogan”, “Rita Bogan – Executive Secretary & Case Management”);
addOption(document.drop_list.SubCat,”DianaGreenberg”, “Diana Greenberg – Underwriting Manager”);
}
if(document.drop_list.Department.value == ‘Marketing’){
addOption(document.drop_list.SubCat,”RonBielefelt”, “Ron Bielefelt – Chief Marketing Officer”);
addOption(document.drop_list.SubCat,”PeterMilanez”, “Peter Milanez – Brokerage Manager”);
addOption(document.drop_list.SubCat,”MarkRBugli”, “Mark R. Bugli – CLU, ChFC “);
addOption(document.drop_list.SubCat,”HowardMandel”, “Howard Mandel – Director of Business Development”);
addOption(document.drop_list.SubCat,”DeborahSanchez”, “Deborah Sanchez – Brokerage Supervisor “);
addOption(document.drop_list.SubCat,”SylviaMariscal”, “Sylvia Mariscal – Life Settlements”);
addOption(document.drop_list.SubCat,”PeterMilanez”, “Peter Milanez – Brokerage Manager”);
addOption(document.drop_list.SubCat,”JosephTanner”, “Joseph Tanner – Brokerage Manager Assistant”, “”);
}
if(document.drop_list.Department.value == ‘Annuities’){
addOption(document.drop_list.SubCat,”SethMoses”, “Seth Moses – Director of Annuities”);
addOption(document.drop_list.SubCat,”SteveAvila”, “Steve Avila – Assistant to Seth Moses”);
}
if(document.drop_list.Department.value == ‘Underwriting/Case Management’){
addOption(document.drop_list.SubCat,”DianaGreenberg”, “Diana Greenberg – Underwriting Manager”);
addOption(document.drop_list.SubCat,”KimberlyFleming”, “Kimberly Fleming – Case Manager “);
addOption(document.drop_list.SubCat,”LarissaBurton”, “Larissa Burton – Case Manager Assistant to Kimberly Fleming”);
addOption(document.drop_list.SubCat,”MariaAntebi”, “Maria Antebi – Case Manager”);
addOption(document.drop_list.SubCat,”LilianaGalvan”, “Liliana Galvan – Case Manager”);
addOption(document.drop_list.SubCat,”KimberlyKoontz”, “Kimberly Koontz – Case Manager Assistant to Liliana Galvan”);
addOption(document.drop_list.SubCat,”ChastaSpikes”, “Chasta Spikes – Case Manager”);
addOption(document.drop_list.SubCat,”SylviaMarsicalShank”, “Sylvia Marsical-Shank – Case Manager”);
addOption(document.drop_list.SubCat,”TriciaRomain “, “Tricia Romain – Case Manager”);
addOption(document.drop_list.SubCat,”BetoRuiz”, “Beto Ruiz – Case Manager”);
addOption(document.drop_list.SubCat,”DavidGarcia”, “David Garcia – Case Manager Assistant”);
}
if(document.drop_list.Department.value == ‘Human Resources’){
addOption(document.drop_list.SubCat,”MarieOkamura”, “Marie Okamura – Human Resources Director”);
}
if(document.drop_list.Department.value == ‘Commissions’){
addOption(document.drop_list.SubCat,”WalterHelbig”, “Walter Helbig, FLMI – Licensing”);
addOption(document.drop_list.SubCat,”KenFong”, “Ken Fong – Licensing”);
addOption(document.drop_list.SubCat,”JimTigrak”, “Jim Tigrak – Commissions”);
}
if(document.drop_list.Department.value == ‘Licensing’){
addOption(document.drop_list.SubCat,”TessSlezak “, “Tess Slezak – Licensing”);
addOption(document.drop_list.SubCat,”ArleneAuerhan “, “ArleneAuerhan – Licensing”);
addOption(document.drop_list.SubCat,”JimTigrak”, “Jim Tigrak – Forms & Supplies”);
}
if(document.drop_list.Department.value == ‘Policy Owner Services’){
addOption(document.drop_list.SubCat,”LanTran”, “Lan Tran – Policy Services”);
addOption(document.drop_list.SubCat,”GianSanchez “, “Gian Sanchez – Receptionist”);
addOption(document.drop_list.SubCat,”ArmonTodd “, “Armon Todd – Office Support”);
}
if(document.drop_list.Department.value == ‘Information Technology’){
addOption(document.drop_list.SubCat,”HenryCholakyan “, “Henry Cholakyan – IT Director”);
}
if(document.drop_list.Department.value == ‘APS’){
addOption(document.drop_list.SubCat,”CarmenAllen “, “Carmen Allen – APS Supervisor”);
}
}
//////////////////

function removeAllOptions(selectbox)
{
var i;
for(i=selectbox.options.length-1;i>=0;i–)
{
//selectbox.options.remove(i);
selectbox.remove(i);
}
}

function addOption(selectbox, value, text )
{
var optn = document.createElement(“OPTION”);
optn.text = text;
optn.value = value;

selectbox.options.add(optn);
}
[/code]

Thanks for any help in advanced!

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @exfakto spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...