_hyperscript icon indicating copy to clipboard operation
_hyperscript copied to clipboard

Practical example for converting Form data to JSON object?

Open kartzke opened this issue 3 years ago • 0 comments

I've searched quite a bit, but I can't seem to find a practical example for converting form data to JSON:

Docs: https://hyperscript.org/docs/#conversions

Values - converts a Form (or other element) into a struct containing its input names/values

I've been playing around with this, but I can't get it to work and now it feels like I'm just guessing. 😅

<div _="on click get the (value of #rightCol) as Values and put it into #resp">click me</div>

In the above code

  • #rightCol is the id assigned to a <form> tag.
  • #resp is just a blank <div id="resp"></div>

I started with this, which works, and was trying to building off of it: <div _="on click put 'hello' into #resp">click me</div>

kartzke avatar Jul 26 '22 08:07 kartzke