I'm not sure how to go about getting a user selected item from a dropdown list. My jade code is pretty short:
extends layout
block content
p This is the CSV page
p <select>
<option value="domain">Domain</option>
<option value="test">Test</option>
<option value="random">Random</option>
<option value="databases">Databases</option>
</select>
form(action="/csvuploader", method="post", enctype="multipart/form-data")
label(for="payload") Select a file to upload:
input#payload(type="file" name="myFile" accept="/*")
br
button#upload Upload
using some busboy methods in my /csvuploader file referenced in the 'action' part of the file upload form I have successfully saved the file. How can I now access the value selected from the dropdown list just before it?
Apologies if this sounds like a really stupid question, I'm new to node.js and forms. Thanks.
You need to move the
<select>
to inside the<form>
element, and also give it a name:After that, you can read the value of the dropdown from
req.body.dropdown
.