code_junkie

What are the CSS secrets to a flexible/fluid HTML form?

Nov 10th, 2011
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. .hide { display: none ; }
  2. .show { display: inline ; }
  3. fieldset { border: #206ba4 1px solid; }
  4. fieldset legend { margin-top: -.4em; font-size: 20px; font-weight: bold; color: #206ba4; }
  5. fieldset fieldset { position: relative; margin-top: 25px; padding-top: 0.75em; background-color: #ebf4fa; }
  6. body { margin: 0; padding: 0; font-family : Verdana; font-size : 12px; text-align: center ; }
  7. #wrapper { margin: 40px auto 0 auto ; }
  8. #myFieldset { width: 213px ;}
  9. #area { margin: 20px ;}
  10. #area select {width: 75px ; float:left ;}
  11. #area label {display: block ; font-size: 1.1em; font-weight: bold; color: #000000;}
  12. #area #selection {display: block ; }
  13. #makes {margin: 5px ; }
  14. #models {margin: 5px ; }
  15.  
  16. var cars = [
  17. {
  18. "makes" : "Honda",
  19. "models" : ['Accord','CRV','Pilot']
  20. },
  21. {
  22. "makes" :"Toyota",
  23. "models" : ['Prius','Camry','Corolla']
  24. } ] ;
  25.  
  26. $(function() {
  27. vehicles = [] ;
  28. for(var i=0; i<cars.length; i++) {
  29. vehicles[cars[i].makes] = cars[i].models ;
  30. }
  31. var options = '' ;
  32. for (var i = 0; i < cars.length; i++) {
  33. options += '<option value="' + cars[i].makes + '">' + cars[i].makes + '</option>';
  34. }
  35. $("#make").html(options); // populate select box with array
  36.  
  37. $("#make").bind("click",
  38. function() {
  39. $("#model").children().remove() ; // clear select box
  40. var options = '' ;
  41. for (var i = 0; i < vehicles[this.value].length; i++) {
  42. options += '<option value="' + vehicles[this.value][i] + '">' + vehicles[this.value][i] + '</option>';
  43. }
  44. $("#model").html(options); // populate select box with array
  45. $("#models").addClass("show") ;
  46. } // bind function end
  47. ); // bind end
  48. });
  49.  
  50. <div id="wrapper">
  51. <fieldset id="myFieldset"><legend>Cars</legend>
  52. <fieldset id="area">
  53. <label>Select Make:</label>
  54. <div id="selection">
  55. <div id="makes">
  56. <select id="make"size="2"></select>
  57. </div>
  58. <div class="hide" id="models">
  59. <select id="model" size="3"></select>
  60. </div>
  61. </div>
  62. </fieldset>
  63. </fieldset>
  64. </div>
Add Comment
Please, Sign In to add comment