Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drop Down list boxes

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have two drop down list boxes on one page. the first drop down has the company names that comes from a table called companyinfo. the second drop down has the name of the company contacts from a table called contactinfo. I want to know how to populate the second drop down list box depending on the selection made on the first drop down list box.

thanx
 
You could do it client side by passing a delimted string with contact associated to each company. In the onChange event of the first combo box you could parse the values for the company and then add them to the 2nd combobox.

here is a javascript funtion to add to a combo.

to use:
AddOptionToList document.myform.cboMyDrop , "1", "MyText"

function AddOptionToList(oCombo, sValue, sText)
{
oCombo.options[oCombo.options.length] = new Option(sText, sValue);
}

let me know if you need more code...

hth
 
I am using asp for the page so im not sure that is going to work
 
I am using it now. It works quite well actually.
I got the idea from looking a carpoint.com.

From the server side create the hidden field with the values pulled from your db. I use a ; to delimit fields and
then * to delimit the record.
on the client use split() on the value of the hidden file split to create the arrays of contacts. Loop thru the arrays and add the contacts to the combo.







 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top