07.html 819 B

1234567891011121314151617181920212223242526272829303132
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title id="page-title">HTMX Demos</title>
  6. <script src="htmx-1-9-12.min.js"></script>
  7. <link rel="stylesheet" href="styles.css"/>
  8. <script>
  9. function getCurrentState() {
  10. return "California";
  11. }
  12. </script>
  13. </head>
  14. <body>
  15. <h1 id="title">Demo</h1>
  16. <h2>Including JavaScript values with <code>hx-vals</code></h2>
  17. <nav hx-get="/autonum/nav" hx-trigger="load"></nav>
  18. <div id="main">
  19. <label for="search">Search Contacts:</label>
  20. <input id="search" name="q" type="search" placeholder="Search Contacts">
  21. <button hx-get="/search"
  22. hx-target="#main .results"
  23. hx-include="#search"
  24. hx-vals='js:{"state":getCurrentState()}'>
  25. Search The Contacts
  26. </button>
  27. <div class="results"></div>
  28. </div>
  29. </body>
  30. </html>