javascript - Show/hide areas of form (im using bootstrap) -
i show different areas on form dependent on selected. can javascript use jquery effects better.
i've seen lots of jquery examples on net cannot see how implement form.
would possible show me 1 example on form , able rest.
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>basic form</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxazxuh4hwsyylfb+j125mxis6mr5fohampbg064zb+afewh94ndvacbm8qnd" crossorigin="anonymous"> </head> <body> <div class="container"> <div class="row"> <div class="content-main col-md-12"> <form> <img src="img/logo.png"> <br><br> metsa wood quick estimation tool <br><br> <div class="col-md-9"> <fieldset class="form-group"> <label for="exampleselect1">type of construction</label> <select class="form-control" id="typeofconstruction"> <option>traditional masonry</option> <option>timber frame</option> </select> </fieldset> <!-- below show if timber frame selected --> <fieldset class="form-group"> <label for="partywalls">which walls party walls?</label> <br><input type="checkbox"> w1 <br><input type="checkbox"> w2 <br><input type="checkbox"> w3 <br><input type="checkbox"> w4 </fieldset> <!-- above show if timber frame selected --> <fieldset class="form-group"> <label for="floorwidtha">floor width a(x)</label> <input type="text" class="form-control" id="floorwidtha" placeholder="enter in mm"> <!--<small class="text-muted">this text a</small>--> <label for="floorwidthb">floor width b(x)</label> <input type="text" class="form-control" id="floorwidthb" placeholder="enter in mm"> <!-- <small class="text-muted">this text a</small>--> </fieldset> <fieldset class="form-group"> <label for="floorwidtha">is there stair opening?</label> <br><input type="checkbox"> </fieldset> <!-- below show if stair opening checked --> <fieldset class="form-group"> <label for="floorwidtha">opening width c(x)</label> <input type="text" class="form-control" id="doorwidthc" placeholder="enter in mm"> <!--<small class="text-muted">this text a</small>--> <label for="floorwidtha">opening width d(x)</label> <input type="text" class="form-control" id="doorwidthd" placeholder="enter in mm"> </fieldset> <!-- above show if stair opening checked --> <button type="submit" class="btn btn-primary">submit</button> </form> </div> <div class="col-md-3"> <img src="img/drawing.jpg"> </div> </div> </div> </div> <!-- <fieldset class="form-group"> <label for="exampleinputpassword1">password</label> <input type="password" class="form-control" id="exampleinputpassword1" placeholder="password"> </fieldset> <fieldset class="form-group"> <label for="exampleselect1">example select</label> <select class="form-control" id="exampleselect1"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select> </fieldset> <fieldset class="form-group"> <label for="exampleselect2">example multiple select</label> <select multiple class="form-control" id="exampleselect2"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select> </fieldset> <fieldset class="form-group"> <label for="exampletextarea">example textarea</label> <textarea class="form-control" id="exampletextarea" rows="3"></textarea> </fieldset> <fieldset class="form-group"> <label for="exampleinputfile">file input</label> <input type="file" class="form-control-file" id="exampleinputfile"> <small class="text-muted">this placeholder block-level text above input. it's bit lighter , wraps new line.</small> </fieldset> <div class="radio"> <label> <input type="radio" name="optionsradios" id="optionsradios1" value="option1" checked> option 1 , that—be sure include why it's great </label> </div> <div class="radio"> <label> <input type="radio" name="optionsradios" id="optionsradios2" value="option2"> option 2 can else , selecting deselect option 1 </label> </div> <div class="radio disabled"> <label> <input type="radio" name="optionsradios" id="optionsradios3" value="option3" disabled> option 3 disabled </label> </div> <div class="checkbox"> <label> <input type="checkbox"> check me out </label> </div> --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/js/bootstrap.min.js" integrity="sha384-vz2wrjmwsjrmw/8u7i6pwi6alo1l79snbrmgidpgiwj82z8ea5lenwvxbmv1pah7" crossorigin="anonymous"></script> </body> </html>
do this.this you
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>basic form</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxazxuh4hwsyylfb+j125mxis6mr5fohampbg064zb+afewh94ndvacbm8qnd" crossorigin="anonymous"> <style type="text/css"> .wfiedls{ display: none; } ba </style> </head> <body> <div class="container"> <div class="row"> <div class="content-main col-md-12"> <form> <img src="img/logo.png"> <br><br> metsa wood quick estimation tool <br><br> <div class="col-md-9"> <fieldset class="form-group"> <label for="exampleselect1">type of construction</label> <select class="form-control" id="typeofconstruction"> <option>traditional masonry</option> <option>timber frame</option> </select> </fieldset> <!-- below show if timber frame selected --> <fieldset class="form-group wfiedls"> <label for="partywalls">which walls party walls?</label> <br><input type="checkbox"> w1 <br><input type="checkbox"> w2 <br><input type="checkbox"> w3 <br><input type="checkbox"> w4 </fieldset> <!-- above show if timber frame selected --> <fieldset class="form-group"> <label for="floorwidtha">floor width a(x)</label> <input type="text" class="form-control" id="floorwidtha" placeholder="enter in mm"> <!--<small class="text-muted">this text a</small>--> <label for="floorwidthb">floor width b(x)</label> <input type="text" class="form-control" id="floorwidthb" placeholder="enter in mm"> <!-- <small class="text-muted">this text a</small>--> </fieldset> <fieldset class="form-group"> <label for="floorwidtha">is there stair opening?</label> <br><input type="checkbox"> </fieldset> <!-- below show if stair opening checked --> <fieldset class="form-group"> <label for="floorwidtha">opening width c(x)</label> <input type="text" class="form-control" id="doorwidthc" placeholder="enter in mm"> <!--<small class="text-muted">this text a</small>--> <label for="floorwidtha">opening width d(x)</label> <input type="text" class="form-control" id="doorwidthd" placeholder="enter in mm"> </fieldset> <!-- above show if stair opening checked --> <button type="submit" class="btn btn-primary">submit</button> </form> </div> <div class="col-md-3"> <img src="img/drawing.jpg"> </div> </div> </div> </div> <script type="text/javascript"> $(document).ready(function(){ $("#typeofconstruction").on('change',function(){ var selectedbalue = $("#typeofconstruction").val(); if (selectedbalue == "timber frame") { $(".wfiedls").slidedown(500); } else{ $(".wfiedls").slideup(500); } }); }); </script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/js/bootstrap.min.js" integrity="sha384-vz2wrjmwsjrmw/8u7i6pwi6alo1l79snbrmgidpgiwj82z8ea5lenwvxbmv1pah7" crossorigin="anonymous"></script> </body> </html>
Comments
Post a Comment