Toggle navigation
Bootsnipp
Bootstrap
For
CSS Frameworks
Bootstrap
Foundation
Semantic UI
Materialize
Pure
Bulma
References
CSS Reference
Tools
Community
Page Builder
Form Builder
Button Builder
Icon Search
Dan's Tools
Diff / Merge
Color Picker
Keyword Tool
Web Fonts
.htaccess Generator
Favicon Generator
Site Speed Test
Snippets
Featured
Tags
By Bootstrap Version
4.1.1
4.0.0
3.3.0
3.2.0
3.1.0
3.0.3
3.0.1
3.0.0
2.3.2
Register
Login
"hide and show div on the basis of select value"
Bootstrap 4.1.1 Snippet by
durgesh361
4.1.1
Preview
HTML
View Full Screen
Fork
Fork this
5.4K
 
4 Fav
Post to Facebook
Tweet this
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script> <style> .form-control{ border-radius:0; } .full_box{ background: #eee; padding: 10px; margin-top: 50px; border-radius: 5px; } .head{ margin-bottom: 30px; } </style> </head> <body> <div class="container"> <div class="full_box"> <h2 class="head text-center" id="head">Div Hide Show with Select</h2> <div class="form_controls"> <div class="row"> <div class="form-group col-md-3"> <select class="form-control" id="select"> <option value="">Select</option> <option value="male">Male</option> <option value="female">Female</option> <option value="both">Transegender</option> </select> </div> </div> <div class="row" style="display: none" id="male"> <div class="form-group col-md-3"> <input type="text" class="form-control" id="pwd" placeholder="name for Male" name="pswd"> </div> <div class="form-group col-md-3"> <input type="text" class="form-control" id="pwd" placeholder="Email for male" name="pswd"> </div> <div class="form-group col-md-3"> <input type="text" class="form-control" id="pwd" placeholder="Mobile for male" name="pswd"> </div> <div class="form-group col-md-3"> <input type="text" class="form-control" id="pwd" placeholder="Password for male" name="pswd"> </div> </div> <div class="row" style="display: none" id="female"> <div class="form-group col-md-3" > <input type="text" class="form-control" id="pwd" placeholder="name for FeMale" name="pswd"> </div> <div class="form-group col-md-3"> <input type="text" class="form-control" id="pwd" placeholder="Email for Female" name="pswd"> </div> <div class="form-group col-md-3"> <input type="text" class="form-control" id="pwd" placeholder="Mobile For FeMale" name="pswd"> </div> <div class="form-group col-md-3"> <input type="text" class="form-control" id="pwd" placeholder="password For Female" name="pswd"> </div> </div> </div> </div> </div> <script> $(document).ready(function(){ $('#select').change(function(){ if($('#select').val()==""){ swal ( "Oops" , "Please Select Any one Option" , "error" ); }else{ } if($('#select').val()=="male"){ $('#male').show(); $('#head').html("You Select Male"); $('#head').css("color","green"); }else{ $('#male').hide(); } if($('#select').val()=="female"){ $('#female').show(); $('#head').html("You Selected Female"); $('#head').css("color","green"); }else{ $('#female').hide(); } if($('#select').val()=="both"){ $('#male').show(); $('#head').html("You Selected Transegender"); $('#head').css("color","green"); $('#female').show(); }else{ } }); }); </script> </body> </html>
Questions / Comments:
Post
Posting Guidelines
Formatting
- Now
×
Close
Donate
BTC: 12JxYMYi6Vt3mx3hcmP3B2oyFiCSF3FhYT
ETH: 0xCD715b2E3549c54A40e6ecAaFeB82138148a6c76