Advertisement
Guest User

Full Circle #67 - WebDev CRUD

a guest
Nov 17th, 2012
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.22 KB | None | 0 0
  1. file = index.html
  2.  
  3. <!DOCTYPE html>
  4. <html>
  5. <head>
  6.     <meta charset="utf-8" />
  7.     <title>Page Title</title>
  8.  
  9.     <meta name="description" content="Page Discription" />
  10.     <meta name="keywords" content="Page Keywords" />
  11.  
  12.     <meta name="author" content="Author Name" />
  13.  
  14.     <meta name="robots" content="index, follow all" />
  15.     <meta name="viewport" content="width=device-width" />
  16.  
  17.     <link rel="stylesheet" type="text/css" href="css/style.css" />
  18.  
  19. </head>
  20. <body>
  21.     <header>
  22.         <h1>FCM - UbuntuVers CRUD</h1>
  23.     </header>
  24.  
  25.     <article>
  26.         <form id='ubuVersForm'>
  27.             <label for="ubuVersNum">Version</label>
  28.             <input type="text" name="ubuVersNum" id="ubuVersNum" value="" placeholder="10.04 LTS" />
  29.  
  30.             <label for="ubuVersName">Release Name</label>
  31.             <input type="text" name="ubuVersName" id="ubuVersName" value="" placeholder="Lucid Lynx" />
  32.  
  33.             <input type="submit" name="submit" id='submit' value="Add" />
  34.  
  35.         </form>
  36.     </article>
  37.  
  38.     <footer>
  39.         <h3>Footer Rock</h3>
  40.     </footer>
  41.    
  42.     <script type="text/javascript" src="js/main.js"></script>
  43. </body>
  44. </html>
  45.  
  46.  
  47.  
  48. file = main.js
  49.  
  50. console.log('js connected');
  51.  
  52. /*******************
  53. // Functions
  54. *******************/
  55.  
  56. //getElementById function
  57. function ge(id) {
  58.     var theElement = document.getElementById(id);
  59.     return theElement;
  60. };
  61.  
  62.  
  63. // process forms
  64. function processForm(formElement) {
  65.     if (formElement.preventDefault) { formElement.preventDefault() };
  66.     console.log('form has been processed.');
  67.  
  68.     // Return false to prevent the default form behavior
  69.     return false;
  70. }
  71.  
  72. /*******************
  73. // Variables
  74. *******************/
  75. var form = ge('ubuVersForm'); // form contains ubuVersForm element
  76.  
  77.  
  78.  
  79.  
  80. /*******************
  81. // Actions
  82. *******************/
  83.  
  84. // Handle form event
  85. if (form.attachEvent) { // if the browser allows for attachEvent
  86.     // attach processForm function to trigger when submit button is pressed
  87.     form.attachEvent("submit", processForm);
  88. } else { // if not then lets just add the ol' event listener
  89.     // when submit is triggered, run the processForm function
  90.     form.addEventListener("submit", processForm);
  91. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement