Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script>
    $(document).ready(function(){
    var options="";
    $("#select1").on('change',function(){
        var value=$(this).val();
        if(value=="1")
        {
             options="<option>Select 2</option>"
                    +"<option value='1'>sub product 1</option>"
                    +"<option value='2'>sub product 2</option>";
            $("#select2").html(options);
        }
        else if(value=="2")
        {
            options="<option>Select 2</option>"
                    +"<option value='3'>sub product 3</option>"
                    +"<option value='4'>sub product 4</option>";
            $("#select2").html(options);
        }
        else if(value=="3")
        {
            options="<option>Select 2</option>"
                    +"<option value='5'>sub product 5</option>"
                    +"<option value='6'>sub product 6</option>";
            $("#select2").html(options);
        }
        else
            $("#select2").find('option').remove()
    });
    });
  </script>
</head>
<body>
<select id="select1">
  <option value="" selected>select</option>
  <option value="1">product 1</option>
  <option value="2">product 2</option>
  <option value="3">product 3</option>
</select>
<select id="select2">
</select>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
chandrakeshkumarpro
0viewers