C# Jadu
  • Home
  • Asp.net
  • Web Design
    • Html
    • Css
    • Java Script
  • Bootstrap
  • Sql
    • Queries
    • Stored Procedures
  • About Me
    • About Myself
    • My Projects
    • My CV
  • Gallery
  • Do you Know?

Sunday, 4 October 2015

How to create a simple dropdown using html and java script ?

 Deepak Chaudhary     10:26     Js     No comments   

Hi Friends...


In this article we learn how to make a dropdown using html and basic java script 
In this drop down user will have to select country then the second dropdown will fill automatically by the reference of  its country,you can use this code in your html page 

Step 1: Html Code


<html>

<script type="text/javascript">

    function deepak(cc) {
        var s = document.myform.cities;
        s.options.length = 0;
        if (cc == "") {
            s.options[s.options.length] = new Option('please select of any item ', '');
        }
        else if (cc == "1") {
            s.options[s.options.length] = new Option('jaipur', '');
            s.options[s.options.length] = new Option('delhi', '');
        }
        else if (cc == "2") {
            s.options[s.options.length] = new Option('nagashakhi', '');
            s.options[s.options.length] = new Option('hiroshima', '');
        }
        else if (cc == "3") {
            s.options[s.options.length] = new Option('karachi', '');
            s.options[s.options.length] = new Option('multan', '');
        }

    }

</script>
<body>

    <form name="myform">
        <div style="margin-left:550px;margin-top:50px; border:groove 2px #ff6a00; width:250px; height:auto; padding:10px;" >
            <select name="option" size="1" onchange="deepak(this.value);">
                <option value="">Choose Country</option>
                <option value="1">INDIA </option>
                <option value="2">JAPAN </option>
                <option value="3">PAKISTAN</option>
            </select>

            <select name="cities" size="1">
            </select>
        </div>
    </form>
</body>
</html>
Your design will look like this 
C# jadu

Demo : 



  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
Email ThisBlogThis!Share to XShare to Facebook
Newer Post Older Post Home

0 comments:

Post a Comment

Most Popular posts

  • How To Create Image wipe Effect With CSS3 Webkit Animation
    Hi Friends... In this article we learn how to create a Image wipe effect with CSS3. CSS transition and animations provide a way for web de...
  • CSS 3D Cube
    Hi Friends... CSS cubes really showcase what CSS has become over the years, evolving from simple color and dimension directives to a lang...
  • Interesting facts about India | Aware Talk
    1. Shampooing is an Indian concept Shampoo was invented in India, not the commercial liquid ones but the method by use of herbs. ...

About Me

Deepak Chaudhary
View my complete profile

Copyright © C# Jadu | Powered by Blogger
Design by Deepak Chaudhary