Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title></title>
- </head>
- <body>
- <table align="center" width="40%" border="2">
- <tr height='100'>
- <td>Formularz</td>
- <td>Wyniki</td>
- </tr>
- <tr height="300">
- <td>
- <form>
- Index: <input type="text" name="a"><br>
- Wartosc: <input type="text" name="b"><br>
- <button type="button" name="btn">Add</button>
- <input type="reset">
- </form>
- </td>
- <td>
- <ul id="results">
- </ul>
- <script>
- const {a, b, btn} = document.forms[0];
- const colors = [];
- const plColorNames = {
- 'czerwony': 'red',
- 'niebieski': 'blue',
- 'zielony': 'green',
- };
- btn.onclick = () => {
- colors.push(b.value);
- results.innerHTML = '';
- colors.forEach(c => {
- let color = document.createElement('li');
- color.textContent = c;
- color.style.color = plColorNames[c] ? plColorNames[c] : 'black';
- results.appendChild(color);
- });
- }
- </script>
- </td>
- </tr>
- </table>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement