|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionForms 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. 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 The source codeThe 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 Here's the teeny-weeny function in where.asp that enables the combo box present in the form in the function getIframe()
{
//to access the element in the Form
//contained in the page called by the IFrame, use
//parent.iframeName.document.iframeFormName.field.value
//here the IFrame element is assigned to the
//hidden variable city in the parent Form
document.form1.city.value=parent.Iframe1.document.form2.elements[0].value;
}
The When a country name is chosen from the combo box, the selected value is passed as a querystring to cities.asp. <select
onchange='document.getElementById("Iframe1").src="cities.asp?country="+
this.value'>
It refers to the following <IFRAME id="Iframe1" name='Iframe1'
FRAMEBORDER=0 SCROLLING='no' WIDTH=120 HEIGHT=40></IFRAME>
Check this Microsoft link for an insight into the
LinksFeedbackLet me know if this article is a killer or a dud. Or whatever you felt.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||