| OLD | NEW |
| (Empty) | |
| 1 <!doctype html> |
| 2 <!-- |
| 3 @license |
| 4 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
| 5 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 6 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 7 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 8 Code distributed by Google as part of the polymer project is also |
| 9 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 10 --> |
| 11 <html> |
| 12 <head> |
| 13 <title>iron-form demo</title> |
| 14 |
| 15 <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-
scale=1, user-scalable=yes"> |
| 16 <meta name="mobile-web-app-capable" content="yes"> |
| 17 <meta name="apple-mobile-web-app-capable" content="yes"> |
| 18 |
| 19 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
| 20 |
| 21 <link rel="import" href="../../paper-input/paper-input.html"> |
| 22 <link rel="import" href="../../paper-button/paper-button.html"> |
| 23 <link rel="import" href="../../paper-styles/paper-styles.html"> |
| 24 <link rel="import" href="../../paper-styles/demo-pages.html"> |
| 25 <link rel="import" href="../iron-form.html"> |
| 26 </head> |
| 27 <style> |
| 28 .wide { |
| 29 width: 474px; |
| 30 } |
| 31 </style> |
| 32 <body> |
| 33 <div class="horizontal center-center layout"> |
| 34 <div> |
| 35 <h4>method="get"</h4> |
| 36 <div class="horizontal-section"> |
| 37 <form is="iron-form" id="formGet" method="get" action="/"> |
| 38 <paper-input name="name" label="Name" required></paper-input> |
| 39 <paper-input name="animal" label="Favourite animal" required></paper-i
nput> |
| 40 <br> |
| 41 |
| 42 <input type="checkbox" name="food" value="donuts" checked> I like donu
ts<br> |
| 43 <input type="checkbox" name="food" value="pizza" required> I like pizz
a<br> |
| 44 <br> |
| 45 |
| 46 <input type="radio" name="color" value="red" checked>Red<br> |
| 47 <input type="radio" name="color" value="blue" checked>Blue<br> |
| 48 <input type="radio" name="color" value="green">Green<br> |
| 49 |
| 50 <br><br> |
| 51 |
| 52 <paper-button raised |
| 53 onclick="clickHandler(event)">Submit</paper-button> |
| 54 <button type="submit">Native Submit</button> |
| 55 </form> |
| 56 </div> |
| 57 </div> |
| 58 |
| 59 <div> |
| 60 <h4>method="post"</h4> |
| 61 <div class="horizontal-section"> |
| 62 <form is="iron-form" id="formPost" method="post" action="/"> |
| 63 <paper-input name="name" label="Name" required></paper-input> |
| 64 <br> |
| 65 <p>Duplicate name <input name="name" required></p> |
| 66 <br><br> |
| 67 |
| 68 <label>Cars</label> |
| 69 <select name="cars"> |
| 70 <option value="volvo">Volvo</option> |
| 71 <option value="saab">Saab</option> |
| 72 <option value="fiat">Fiat</option> |
| 73 <option value="audi">Audi</option> |
| 74 </select> |
| 75 |
| 76 <br><br> |
| 77 <label>Browsers</label> |
| 78 <input list="browsers" name="browsers" required> |
| 79 <datalist id="browsers"> |
| 80 <option value="Internet Explorer"> |
| 81 <option value="Firefox"> |
| 82 <option value="Chrome"> |
| 83 <option value="Opera"> |
| 84 <option value="Safari"> |
| 85 </datalist> |
| 86 <br><br> |
| 87 |
| 88 <label>Pick a number</label> |
| 89 <input type="range" name="number" min="1" max="100"> |
| 90 |
| 91 <br><br><br> |
| 92 <paper-button raised |
| 93 onclick="clickHandler(event)">Submit</paper-button> |
| 94 <button type="submit">Native Submit</button> |
| 95 </form> |
| 96 </div> |
| 97 </div> |
| 98 </div> |
| 99 |
| 100 <br><br> |
| 101 <div class="layout vertical center-center"> |
| 102 <div> |
| 103 <h4>Submitted form data</h4> |
| 104 <div class="horizontal-section wide"> |
| 105 <div id="output"></div> |
| 106 </div> |
| 107 </div> |
| 108 </div> |
| 109 |
| 110 <script> |
| 111 document.getElementById('formGet').addEventListener('iron-form-submit', disp
lay); |
| 112 document.getElementById('formPost').addEventListener('iron-form-submit', dis
play); |
| 113 |
| 114 function display(event) { |
| 115 var output = document.getElementById('output'); |
| 116 output.innerHTML = JSON.stringify(event.detail); |
| 117 } |
| 118 |
| 119 function clickHandler(event) { |
| 120 Polymer.dom(event).localTarget.parentElement.submit(); |
| 121 } |
| 122 </script> |
| 123 </body> |
| 124 |
| 125 </html> |
| OLD | NEW |