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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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 / 25
    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


    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! Driving Business Success with Rational Process Library

    Join this webcast, to learn how the Rational Process Library can help with compliance issues, drive process improvement, and assist in service-oriented architecture (SOA) or Agile development. We will take a peek into the Rational Process Library with content around software and systems engineering (including RUP), operations and systems management, program and portfolio management, and asset and SOA governance.
    FREE! Go There Now!


    NEW! IBM – Taking Web 2.0 to Work

    David Barnes, Lead Evangelist for IBM Emerging Internet Technologies will discuss aspects of Web 2.0 that bring value to corporations, academia, and government. He'll also discuss IBM's vision around Web 2.0, including the importance of remixability and consumability. The discussion will culminate with examples of various IBM Software Group solutions you can use to get ahead of the Web 2.0 adoption curve.
    FREE! Go There Now!


    NEW! A Layered approach to delivering security-rich Web applications

    As businesses grow increasingly dependent upon Web applications to provide services to customers, employees and partners, these complex applications become more difficult to secure. Although traditional security solutions protect Internet infrastructure layers, they do not guard against HTTP and HTML attacks. Many organizations that conduct security testing still deploy applications that allow attackers to manipulate their logic and wreak havoc on their business. To mitigate this risk, development and delivery teams must address Web application security throughout the lifecycle, addressing the many layers detailed in this paper.
    FREE! Go There Now!


    NEW! Best practices for software analysis: An introduction to the IBM Rational Software Analyzer application

    This whitepaper presents the benefits of successfully introducing static analysis into your organization using IBM Rational Software Analyzer. Additionally, it identifies some common pitfalls that can hinder the effective use of static analysis tooling as well as presents 10 simple strategies designed to help you quickly realize the value of static analysis using Rational Software Analyzer.
    FREE! Go There Now!


    NEW! Cook up Web sites fast with CakePHP, Part 4: Use CakePHP&apos;s Session and Request Handler components

    CakePHP is a stable production-ready, rapid-development aid for building Web sites in PHP. This "Cook up Web sites fast with CakePHP" series shows you how to build an online product catalog using CakePHP.
    FREE! Go There Now!


    NEW! Evaluate IBM Rational Developer for System i V7.1

    Download a free trial version of IBM Rational Developer for System i V7.1, which provides a complete development environment for traditional i5/OS application development. IBM Rational Developer for System i is a new eclipse-based workstation offering for i5/OS application development that provides a comprehensive Integrated Development Environment for edit/compile/debug of traditional RPG/COBOL/C/C++ i5/OS applications.
    FREE! Go There Now!


    NEW! Hello World: Monitor a simple business process using WebSphere Business Monitor V6.0.2

    This tutorial shows new users of IBM WebSphere Business Monitor Version 6.0.2 how to perform the "Hello World" equivalent for monitoring business process applications. It is intended to help you get familiar with the capabilities of the product.
    FREE! Go There Now!


    NEW! Hello World: WebSphere Service Registry and Repository

    Manage, govern, and share services across your organization by using WebSphere Service Registry and Repository. Follow the hands-on exercises to learn how to navigate the Web interface to publish, find, reuse, and update services.
    FREE! Go There Now!


    NEW! IBM Rational Systems Development e-Kit

    As systems increase in complexity, communication between systems and software teams becomes more and more difficult. Now, there’s a way to improve product quality and communication.<br />Read the “Model Driven Systems Development” white paper to see how. Also included in this kit are more educational white papers, customer examples, tutorials, informative Webcasts, and best practices for designing, building and managing systems.<br />
    FREE! Go There Now!


    NEW! Webcast: Application security testing and Web compliance

    Join the IBM Watchfire team for an informative discussion on techniques and best practices to proactively manage Web application security and how to effectively build application security testing into the software development lifecycle (SDLC). In this Software Delivery Platform webcast you will learn: How to better understand potential web application security vulnerabilities, best practices and how to effectively integrate application security testing into the software development lifecycle, the importance of detecting and removing software vulnerabilities during application development.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    ASP.NET ARTICLES

    - Adding Content to a Static ASP.NET Website
    - Building a Static ASP.NET Website in a Basic...
    - Develop Your First ASP.NET Website with Visu...
    - Run ASP.NET in Windows XP Home with Cassini ...
    - How to Test a Web Application
    - How to Add Code and Validation Controls to a...
    - Working in Source and Split Views to Build a...
    - How to Build a Web Form for a One-Page Web A...
    - How to Develop a One-Page Web Application
    - An ASP.NET Web Application in Action
    - Developing ASP.NET Web Applications
    - An Introduction to ASP.NET Web Programming
    - Introduction to the ADO.NET Entity Framework...
    - Completing an In-Text Advertising System und...
    - Programming an In-Text Advertising System un...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek