Click here to Skip to main content
14,334,763 members

Creating a Dynamic Combo Box w/o Refreshing Page

Rate this:
4.56 (30 votes)
Please Sign up or sign in to vote.
4.56 (30 votes)
30 Jul 2003
..using IFRAME.


Forms involving a dynamically-linked combo box have to waste a server-trip to fetch the values from the database to populate that combo box based on the value of a dependent combo box. Links to a number of approaches to handle dynamically-linked lists are listed in Charles Carol's excellent online book here. I discovered a cross-browser (well almost cross-browser ;-). I tested the code in IE 5, Netscape 6 & 7 and Mozilla 1.0 & it worked fine. IFRAME is not supported in NN 4.x and lower) method to populate a dynamically-linked List Box without refreshing the page, by using the IFRAME tag.

On selecting a country from the first combo box, the cities in that country, retrieved from the database are populated into the second combo. The second combo is actually present inside a frame-border-less IFRAME. A teeny-weeny JavaScript function allows the value of the combo box to be available to the outer form & be submitted.

The source code

The zipped source code file consists of 2 ASP files - where.asp & cities.asp & a MDB file City.mdb containing a table of countries & cities.

where.asp is the page that you have to load first, using IIS. It has a reference to the cities.asp page through the IFRAME.

Here's the teeny-weeny function in where.asp that enables the combo box present in the form in the IFRAME to be accessed by the parent form:

function getIframe()
//to access the element in the Form 
//contained in the page called by the IFrame, use
//here the IFrame element is assigned to the 
//hidden variable city in the parent Form[0].value;


The city element referred in the script above is a hidden tag.

When a country name is chosen from the combo box, the selected value is passed as a querystring to cities.asp.



It refers to the following IFRAME defined in the same page.

<IFRAME id="Iframe1" name='Iframe1' 


Check this Microsoft link for an insight into the IFRAME tag. If you're impressed with what can be done with IFRAME, take a look at Searchlite v2. Also take a look at two other related articles:



Let me know if this article is a killer or a dud. Or whatever you felt.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

'Anil' Radhakrishna
Web Developer
India India
'Anil' Radhakrishna is a seasoned developer who enjoys working with Microsoft tools & technologies. He blogs quite regularly about his little discoveries and technical experiments on his blog called Tech Tips, Tricks & Trivia. He loves building mash-ups using public Web APIs.

Comments and Discussions

Questioniframe Pin
jguemez22-Apr-11 6:15
memberjguemez22-Apr-11 6:15 
GeneralCreating a Dynamic Combo Box w/o Refreshing Page Pin
RayRit18-Nov-09 13:13
memberRayRit18-Nov-09 13:13 
QuestionCan you help me out by doing the same With PHP Pin
arunudu14-Dec-07 1:07
memberarunudu14-Dec-07 1:07 
Questioncan you upgrade this in Pin
pabidi27-Jun-07 1:33
memberpabidi27-Jun-07 1:33 
GeneralExpansion to 3 combo box Pin
geervanibs4-Jun-07 20:16
membergeervanibs4-Jun-07 20:16 
GeneralThanks 4 this Pin
Cristiano Shrestha22-May-07 19:06
memberCristiano Shrestha22-May-07 19:06 
QuestionHow to expand the select box to be 3 or more select box??? Pin
neo_msi202-May-07 22:05
memberneo_msi202-May-07 22:05 
GeneralThanks so much! [modified] Pin
enfleshjsc29-Mar-07 5:05
memberenfleshjsc29-Mar-07 5:05 
QuestionHow do i extend it to three combo boxes Pin
Member 5196498-Aug-03 6:15
memberMember 5196498-Aug-03 6:15 
AnswerRe: How do i extend it to three combo boxes Pin
geervanibs4-Jun-07 20:25
membergeervanibs4-Jun-07 20:25 
GeneralYou have a creative solution but... Pin
kbuchan4-Aug-03 2:19
memberkbuchan4-Aug-03 2:19 
GeneralRe: You have a creative solution but... Pin
Richard Deeming4-Aug-03 22:56
mveRichard Deeming4-Aug-03 22:56 
GeneralJSP Pin
Juan Carlos Montenegro18-Dec-02 5:45
memberJuan Carlos Montenegro18-Dec-02 5:45 
Generalsometinh different Pin
tommy skaue12-Nov-02 0:18
membertommy skaue12-Nov-02 0:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Posted 8 Nov 2002


29 bookmarked