"Sample Form"
Bootstrap 3.1.0 Snippet by escapedlion

<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!DOCTYPE html> <html> <head> <link href="http://netdna.bootstrapcdn.com/bootswatch/3.0.3/bootstrap/bootstrap.min.css" rel="stylesheet" title="theme"> <link href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet" title="theme"> <style> * { transition: all 1s ease-in-out; } </style> </head> <body classs="bootstrap"> <div class="wrapper"> <div class="container"> <div class="row"> <div class="bs-docs-section"> <div class="row"> <div class="col-lg-12"> <div class="page-header"> <h1 id="forms"><span class="current_theme">Bootstrap</span> Theme</h1> </div> </div> </div> </div> <div class="row"> <div class="col-lg-4"> <div class="well"> <form class="bs-example form-horizontal"> <fieldset> <legend>Theme Selector</legend> <div class="form-group"> <label for=""theme_name"" class="col-lg-4 control-label">Theme</label> <div class="col-lg-8"> <select class="form-control" id="theme_name" name="theme_name"> <option value="amelia"> Amelia </option> <option value="bootstrap"> Default </option> <option value="cerulean"> Cerulean </option> <option value="cosmo"> Cosmo </option> <option value="cyborg"> Cyborg </option> <option selected value="flatly"> Flatly </option> <option value="journal"> Journal </option> <option value="readable"> Readable </option> <option value="simplex"> Simplex </option> <option value="slate"> Slate </option> <option value="spacelab"> Spacelab </option> <option value="united"> United </option> <option value="yeti"> Yeti </option> <option value="whiteplum"> WhitePlum </option> </select> </div> </div> <div class="form-group"> <div class="col-lg-8 col-lg-offset-4"> <button type="submit" class="btn btn-primary">Submit</button> </div> </div> </fieldset> </form> </div> </div> </div> </div> </div> </body> </html>
function save_settings() { localStorage.setItem("background_color" , $( "#background_color" ).val()); localStorage.setItem("text_color", $( "#text_color" ).val()); localStorage.setItem("text_size", $( "#text_size" ).val()); localStorage.setItem("theme_name", $( "#theme_name" ).val()); localStorage.setItem("icon_label",$('input[name="icon_label"]:checked').val()); apply_preferences_to_page(); } function load_settings() { var background_color = localStorage.getItem( "background_color" ); var text_color = localStorage.getItem( "text_color" ); var text_size = localStorage.getItem( "text_size" ); var theme_name = localStorage.getItem( "theme_name" ); var icon_label = localStorage.getItem( "icon_label" ); $("#background_color").val(background_color); $("#text_color").val(text_color); $("#text_size").val(text_size); $("#theme_name").val(theme_name); $("#icon_label").val(icon_label); apply_preferences_to_page(); } function apply_preferences_to_page() { var background_color = localStorage.getItem( "background_color"); var text_color = localStorage.getItem("text_color"); var text_size = localStorage.getItem("text_size"); var theme_name = localStorage.getItem("theme_name"); var stored_icon_label = localStorage.getItem("icon_label"); $("body").attr("class",theme_name); $('link[title="theme"]').attr('href','http://netdna.bootstrapcdn.com/bootswatch/3.0.3/'+theme_name+'/bootstrap.min.css'); $(".current_theme").html(theme_name); $(".label-filter").html(theme_name); if(stored_icon_label=="Yes") { $(".icon_label").show(); } if(stored_icon_label=="No") { $(".icon_label").hide(); } display_preferences(); } function display_preferences() { //the variable that will hold the results var dataLog = ""; var i = 0; //how many items are in the database starting with zero var logLength = localStorage.length-1; dataLog = "<thead><tr class='active'><th>Item Name</th><th>Item Data</th></tr></thead><tbody>" //now we are going to loop through each item in the database for (i = 0; i <= logLength; i++) { //lets setup some variables for the key and values var itemKey = localStorage.key(i); var itemData = localStorage.getItem(itemKey); //now that we have the item, lets add it to the table dataLog += '<tr><td>'+itemKey+'</td><td>'+itemData+'</td></tr>'; } //if there were no items in the database if (dataLog == "") dataLog = '<li class="empty">Log Currently Empty</li>'; //update the ul with the list items $("#theLog").html(dataLog); } $(function() { load_settings(); $('form#preferences').submit(function(event){ event.preventDefault(); save_settings(); }); });

Related: See More


Questions / Comments: