<script>
jQuery(document).ready( init )
function init()
{
var countries = new DbNetCombo("countries");
var cities = new DbNetCombo("cities");
var customers = new DbNetCombo("customers");
with (customers)
{
sql = "select CustomerID,CompanyName,ContactName,ContactTitle,Address,City,Region,PostalCode,Country,Phone,Fax from customers where city = ? order by companyname"
bind("onChange", displayCustomer);
bind("onItemsLoaded", displayCustomer);
bind("onItemsCleared", displayCustomer);
parameters = {city : ""}
}
with (cities)
{
sql = "select distinct city from customers where country = ? order by city";
parameters = {country : ""}
addLinkedControl(customers)
}
with (countries)
{
connectionString = "SamplesDatabase"
addEmptyOption = true
emptyOptionText = "Please select a Country ...";
sql = "select distinct country from customers order by country"
addLinkedControl(cities)
initialize()
}
}
function displayCustomer(combo)
{
var ids = ["contactname","address","city","region","country","phone","fax"]
for (var i=0; i < ids.length; i++)
{
var val = "";
var opt = combo.selectedOption();
if (opt.length > 0)
if (opt[0].value != "")
val = opt[0].getAttribute(ids[i]);
jQuery("#" + ids[i]).val(val);
}
}
</script>