SunQuest
 
       ASP.NET
  Home arrow ASP.NET arrow Dynamically add content to one Dropdownlis...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Dynamically add content to one Dropdownlist on the basis of selection of other Dropdownlist
By: aspfree
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 2 stars2 stars2 stars2 stars2 stars / 21
    2002-08-11

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    function FillCity() { str = document.all["MyDropDownList"].value ; document.all["DropDownList"].length=0; soption = "Select City" st = new Option(soption,""); document.all["DropDownList"].add(st) for (i=1;i function FillCity() { str = document.all["MyDropDownList"].value ; document.all["DropDownList"].length=0; soption = "Select City" st = new Option(soption,""); document.all["DropDownList"].add(st) for (i=1;i<8;i++){ if (JCountry[i] == str){ soption = JCity[i]; st = new Option(soption,soption); document.all["DropDownList"].add(st) } } }

    Here is the code.

    <script runat="server" >
    public void Page_Load ( object sender, EventArgs e)
    {
    MyDropDownList.Attributes.Add("OnChange", "FillCity()") ;
    MyDropDownList.Items.Add(new ListItem("Selecy Country", ""));
    MyDropDownList.Items.Add(new ListItem("India", "IND"));
    MyDropDownList.Items.Add(new ListItem("United Kingdom", "UK"));
    MyDropDownList.Items.Add(new ListItem("United States", "US"));
    MyDropDownList.Items.Add(new ListItem("France", "FR"));
    MyDropDownList.Items.Add(new ListItem("Srilanka", "SR"));
    DropDownList.Items.Add(new ListItem("Selecy City", ""));
    String strString;
    strString = "<script language='JavaScript' >"; 
    strString += "JCountry = new Array(15);";
    strString += "JCountry[1] = 'IND';";
    strString += "JCountry[2] = 'IND';";
    strString += "JCountry[3] = 'US';";
    strString += "JCountry[4] = 'US';";
    strString += "JCountry[5] = 'US';";
    strString += "JCountry[6] = 'UK';";
    strString += "JCountry[7] = 'UK';";
    strString += "JCity = new Array(20);";
    strString += "JCity[1] = 'Mumbai';";
    strString += "JCity[2] = 'Pune';";
    strString += "JCity[3] = 'New York';";
    strString += "JCity[4] = 'Chicago';";
    strString += "JCity[5] = 'Washignton';";
    strString += "JCity[6] = 'London';";
    strString += "JCity[7] = 'Leeds';";
    strString += "<" + "/" + "script>";
    Response.Write(strString);
    }
    public void alphaSubmit(object sender , EventArgs e)
    {

    }
    </script>

    <script language="JavaScript" >
    function FillCity()
    {
    str = document.all["MyDropDownList"].value ;
    document.all["DropDownList"].length=0;
    soption = "Select City"
    st = new Option(soption,"");
    document.all["DropDownList"].add(st)
    for (i=1;i<8;i++){
    if (JCountry[i] == str){
    soption = JCity[i];
    st = new Option(soption,soption);
    document.all["DropDownList"].add(st)
    }

    }

    }
    </script>

    <H1>Combination OF C# and JavaScript </H1><br>
    By Laxmikant Shrotri
    <Form name="MyForm" runat="server">
    <asp:Dropdownlist id="MyDropDownList" DataValueField = "CountryCode" DataTextField = "Country" runat="server" />
    <asp:Dropdownlist id="DropDownList" DataValueField = "CountryCode" DataTextField = "Country" runat="server" /> 

    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More ASP.NET Articles
    More By aspfree

     

    IBM® developerWorks developerWorks - FREE Tools!


    NEW! Addressing software-as-a-service challenges using Tivoli security and WebSphere solutions

    Building a software-as-a-service solution requires addressing a few key technical challenges. In this webcast, we'll focus on the role of IBM Tivoli Directory Server and WebSphere Portlet Factory in creating a Software as a Service solution. We will demonstrate how to use Tivoli Directory Server to prevent the user population of one tenant from accessing the virtual portal and portlet components of another tenant. We will also use the dynamic profile capability of WebSphere Portlet Factory to create multiple highly customized applications from one code base.
    FREE! Go There Now!


    NEW! Application Development Tools for the Mainframe Developer

    You probably have thousands of lines of COBOL code loaded with business intelligence and being used to run your business, along with an army of developers maintaining these applications. Learn how to prepare your applications and developers so you can keep that competitive edge and move to a service-oriented architecture with the IBM Rational Enterprise Modernization solutions. Replay is available for 9 months.
    FREE! Go There Now!


    NEW! IBM Rational AppScan Standard Edition V7.7

    Secure your Web applications with IBM Rational AppScan Standard Edition V7.7, previously known as Watchfire AppScan. This Web application security testing tool automates vulnerability assessments and scans and tests for common Web application vulnerabilities. Visit IBM developerWorks to download a free trial of IBM Rational AppScan Standard Edition V7.7.
    FREE! Go There Now!


    NEW! Improve your build process with IBM Rational Build Forge, Part 2: Automate builds for a real-world Tomcat project

    Learn how Rational Build Forge can extend a simple compile and package build process by adding customization and deployment capability. Go from a manual method to automating: checking for code changes; getting the latest source; compiling and packaging; customizing; copying to and restarting a deployment server; and sending e-mail notification that a new version is available.
    FREE! Go There Now!


    NEW! Rational Asset Manager eKit

    Learn how to do more with your reusable assets with the free Rational Asset Manager eKit. The eKit includes demos on how Rational Asset Manager tracks and audits your assets in order to utilize them for reuse. Plus you’ll find white papers and a Webcast that discuss the challenges of a Service Oriented Architecture and how Rational Asset Manager can provide quick and effective solutions.
    FREE! Go There Now!


    NEW! Rational Build Forge Express eKit

    Rational Build Forge Express Edition is an automation framework that packages the latest enterprise-grade technologies into a reliable, flexible and robust configuration designed and priced specifically for small to midsize businesses. The new Rational Build Forge Express eKit provides you with valuable resources – including a case study, podcast, demo, and articles – to help you increase staff productivity, compress development cycles and deliver better software, fast.
    FREE! Go There Now!


    NEW! Run your first CICS application on a PC using TXSeries for Windows

    Learn the basics of the IBM Customer Information Control System (CICS). With a hands-on exercise, learn how to get your first CICS application up and running on your desktop using TXSeries V6.1 for Windows. The tutorial shows you how to download and install a free trial version of TXSeries V6.1.
    FREE! Go There Now!


    NEW! Software Change and Configuration Management Solution Guidelines

    This whitepaper provides areas to consider when evaluating any software configuration management solution. It addresses how the IBM solutions (Rational ClearCase and Rational ClearQuest) meet the needs and requirements of both project leaders and developers to provide successful Software Change and Configuration Management.
    FREE! Go There Now!


    NEW! The dirty dozen: preventing common application-level hack attacks

    As organizations have grown increasingly dependent on online software, the risk of malicious attacks has also become far more serious. Fortunately, well-governed organizations can protect their Web applications by injecting vulnerability assessments and ethical hacks into their software development and delivery processes. This paper describes 12 of the most common hacker attacks and provides basic rules that you can follow to help create more hack-resistant Web applications.
    FREE! Go There Now!


    NEW! Try the IBM SOA Sandbox for People

    Visit IBM developerWorks to try the IBM SOA Sandbox for people. The SOA Sandbox for people provides a trial environment with the necessary tooling and components required to enable consistent human and process interaction and collaboration, showing how you can improve user experience and business productivity.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    ASP.NET ARTICLES

    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX
    - Building a Simple Storefront with LINQ
    - Developing a Dice Game Using ASP.NET Futures...
    - Completing an ASP.NET AJAX Server-Centric Ba...
    - Information Management for an ASP.NET AJAX S...
    - Comment and Order Management for an ASP.NET ...
    - Back-end Management Tasks for an ASP.NET AJA...
    - User Information Management for an ASP.NET A...
    - Adding Comments and Search to an ASP.NET AJA...
    - Order-Related Modules for an ASP.NET AJAX Se...
    - User and Role Management for an ASP.NET AJAX...
    - Programming an ASP.NET AJAX Server-Centric B...

    Click Here




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway