Click here to Skip to main content
11,930,231 members (39,064 online)
Click here to Skip to main content
Add your own
alternative version


29 bookmarked

Creating a Dynamic Combo Box w/o Refreshing Page

, 30 Jul 2003
Rate this:
Please Sign up or sign in to vote.
..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 Wink | ;-) . 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.

You may also be interested in...

Comments and Discussions

Questioniframe Pin
jguemez22-Apr-11 7:15
memberjguemez22-Apr-11 7:15 
GeneralCreating a Dynamic Combo Box w/o Refreshing Page Pin
RayRit18-Nov-09 14:13
memberRayRit18-Nov-09 14:13 

Its not working with multi select Combo Box .


function getIframe()
<iframe id="iframe1" name='iframe1' FRAMEBORDER=0 SCROLLING='no' WIDTH=120 HEIGHT=40> </iframe>


If I am selecting two citites its showing only one.
How to solve this.

QuestionCan you help me out by doing the same With PHP Pin
arunudu14-Dec-07 2:07
memberarunudu14-Dec-07 2:07 
Questioncan you upgrade this in Pin
pabidi27-Jun-07 2:33
memberpabidi27-Jun-07 2:33 
GeneralExpansion to 3 combo box Pin
geervanibs4-Jun-07 21:16
membergeervanibs4-Jun-07 21:16 
GeneralThanks 4 this Pin
Cristiano Shrestha22-May-07 20:06
memberCristiano Shrestha22-May-07 20:06 
QuestionHow to expand the select box to be 3 or more select box??? Pin
neo_msi202-May-07 23:05
memberneo_msi202-May-07 23:05 
GeneralThanks so much! [modified] Pin
enfleshjsc29-Mar-07 6:05
memberenfleshjsc29-Mar-07 6:05 
QuestionHow do i extend it to three combo boxes Pin
bibha8-Aug-03 7:15
memberbibha8-Aug-03 7:15 
AnswerRe: How do i extend it to three combo boxes Pin
geervanibs4-Jun-07 21:25
membergeervanibs4-Jun-07 21:25 
GeneralYou have a creative solution but... Pin
kbuchan4-Aug-03 3:19
memberkbuchan4-Aug-03 3:19 
GeneralRe: You have a creative solution but... Pin
Richard Deeming4-Aug-03 23:56
memberRichard Deeming4-Aug-03 23:56 
GeneralJSP Pin
Juan Carlos Montenegro18-Dec-02 6:45
sussJuan Carlos Montenegro18-Dec-02 6:45 
Generalsometinh different Pin
tommy skaue12-Nov-02 1:18
membertommy skaue12-Nov-02 1: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.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.151126.1 | Last Updated 31 Jul 2003
Article Copyright 2002 by 'Anil' Radhakrishna
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid