Is there a way to use select input value in a template?

Can I somehow pass select input value to other partials

<select id="type" name="type">
     <option value="1">1</option>
     <option value="2">2</option>
</select>

{{ $include_dict = dict "product_page" . }}
{{ partial "buy_button.html" $include_dict }}

I guess I can’t use js for this.

Can I access selected value in a template in any way?

Hugo is a static site generator. The HTML is generated before a user would interact with a page/form.

2 Likes

You could use JavaScript. But using a static site generator for a highly dynamic site (which your “buy_button” seems to indicate) is probably not the best way to go – you need a lot of server logic anyway.

I am integrating hugo with snipcart. It works well, and I have some workarounds for this data that I need from select. But I’m still curious.