Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- file = index.html
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8" />
- <title>Page Title</title>
- <meta name="description" content="Page Discription" />
- <meta name="keywords" content="Page Keywords" />
- <meta name="author" content="Author Name" />
- <meta name="robots" content="index, follow all" />
- <meta name="viewport" content="width=device-width" />
- <link rel="stylesheet" type="text/css" href="css/style.css" />
- </head>
- <body>
- <header>
- <h1>FCM - UbuntuVers CRUD</h1>
- </header>
- <article>
- <form id='ubuVersForm'>
- <label for="ubuVersNum">Version</label>
- <input type="text" name="ubuVersNum" id="ubuVersNum" value="" placeholder="10.04 LTS" />
- <label for="ubuVersName">Release Name</label>
- <input type="text" name="ubuVersName" id="ubuVersName" value="" placeholder="Lucid Lynx" />
- <input type="submit" name="submit" id='submit' value="Add" />
- </form>
- </article>
- <footer>
- <h3>Footer Rock</h3>
- </footer>
- <script type="text/javascript" src="js/main.js"></script>
- </body>
- </html>
- file = main.js
- console.log('js connected');
- /*******************
- // Functions
- *******************/
- //getElementById function
- function ge(id) {
- var theElement = document.getElementById(id);
- return theElement;
- };
- // process forms
- function processForm(formElement) {
- if (formElement.preventDefault) { formElement.preventDefault() };
- console.log('form has been processed.');
- // Return false to prevent the default form behavior
- return false;
- }
- /*******************
- // Variables
- *******************/
- var form = ge('ubuVersForm'); // form contains ubuVersForm element
- /*******************
- // Actions
- *******************/
- // Handle form event
- if (form.attachEvent) { // if the browser allows for attachEvent
- // attach processForm function to trigger when submit button is pressed
- form.attachEvent("submit", processForm);
- } else { // if not then lets just add the ol' event listener
- // when submit is triggered, run the processForm function
- form.addEventListener("submit", processForm);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement