I have done the same like that...here i am filling two dropdownlist based on one dropdown change....
here is the code in _javascript_:
// fires on Onload of page and Onchange of Carrier and Country to fill service types and Packages
// called in active search _javascript_ funcitons and many places to fill user settings
function LoadCarrierandServiceTypes()
{
var servicetype = document.getElementById("<%=CmbServiceType.ClientID%>");
var packaging = document.getElementById("<%=cmbPackaging.ClientID%>");
var carrierId = document.Form1.cmbCarrier.options[document.Form1.cmbCarrier.selectedIndex].value;
var Country = document.Form1.cmbCountry.options[document.Form1.cmbCountry.selectedIndex].value;
var Isinternational;
if(Country =="US")
Isinternational = false;
else
Isinternational = true;
if (carrierId > 0)
{
var companyID = getCookie("ps_company_id");
var contactID = getCookie("CONTACT_ID");
//CreateAirbills is defined by Ajax.Net because that's the name of the type we registered
CreateAirbills.populateServiceTypes(carrierId,companyID,contactID,Isinternational,LoadCarrierandServiceTypes_CallBack);
CreateAirbills.populatePackagings(carrierId,LoadCarrierandPackaging_CallBack);
}
else
{
//clear the dropdown
while (servicetype.options.length > 1) {
servicetype.options
[servicetype.options.length-1] = null;
}
while (packaging.options.length > 1) {
packaging.options[packaging.options.length-1] = null;
}
}
}
//callback we told
Ajax.Net to pass the response tos
function LoadCarrierandServiceTypes_CallBack(response)
{
//if the server side code threw an exception
if (response.error != null)
{
alert(response.error
); //we should probably do better than this
return;
}
else if (response.value == null)
{
alert ("debug: LoadCarrierandPackaging_CallBack - response.value is null");
}
var resserviceTypes = response.value;
//if the response wasn't what we expected
//ServiceTypes dropdown
servicetype = document.getElementById("<%=CmbServiceType.ClientID%
>");
servicetype.options.length = 0; //reset the Service Types dropdown
var doc = servicetype.ownerDocument; // Start to add static text to dropdown
if (!doc)
doc =
servicetype.document;
var opt = doc.createElement('OPTION');
opt.value = "0";
opt.text = "Select a Service";
servicetype.options.add(opt, 0);
//note that this is _javascript_ casing and the L in length is lowercase for arrays
for (var i = 0; i < resserviceTypes.Rows.length; ++i)
{
servicetype.options[servicetype.options.length] = new Option(resserviceTypes.Rows[i].DSS_Name, resserviceTypes.Rows[i].service_type_id);
}
}
//callback we told Ajax.Net to pass the response tos
function LoadCarrierandPackaging_CallBack(response)
{
//if the server side code threw an exception
if (response.error
!= null)
{
alert(response.error); //we should probably do better than this
return;
}
else if (response.value == null)
{
alert ("debug: LoadCarrierandPackaging_CallBack -
response.value is null");
}
var resPackaging = response.value;
// Packaging Dropdown
packaging = document.getElementById("<%=cmbPackaging.ClientID%>");
packaging.options.length = 0; //reset the Packaging dropdown
var doc = packaging.ownerDocument; // Start to add static text to dropdown
if (!doc)
doc = packaging.document;
var opt =
doc.createElement('OPTION');
opt.value = "0";
opt.text = "Select Packaging";
packaging.options.add(opt, 0); //end to add static text to dropdown
//note that this is _javascript_ casing and the L in length is lowercase for arrays
for (var i = 0; i < resPackaging.Rows.length; ++i)
{
packaging.options[packaging.options.length] = new Option(resPackaging.Rows[i].packaging_description, resPackaging.Rows[i].id);
}
}
On 4/18/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I'm a Newbie and I have a basic question.
>
> I have 2 dropdown the first with countries and the second with
> departments when i change the first I would like to have the related
> departments.
>
> It works fine when I return System.Web.UI.HtmlControls.HtmlSelect from
> VB function and
> innerHtml in _javascript_. BUT I don't want to use innerHtml I would have
> preferred to retrieve a Dataset or Array and add it in the _javascript_
> to a real <option select id= ???> in my HTML page looping through the
> object (Dataset or Array).
>
> All welcome
>
> Thx in advance
>
> Attilio
> Belgium
>
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ajax.NET Professional" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/ajaxpro
The latest downloads of Ajax.NET Professional can be found at http://www.ajaxpro.info
-~----------~----~----~----~------~----~------~--~---
- [ajaxpro] Dropdown list [EMAIL PROTECTED]
- [ajaxpro] Re: Dropdown list N a g a s a i
- [ajaxpro] Re: Dropdown list Attilio Mucciaccio
