I need to retrieve the selected dropdown value from this code block in a .hbs file...
<div class="section-color">
<div class="jumbotron jumbotron-md center-block">
<h2> Cluster</h2>
<p>This cluster was calculated using kmeans with k = </p>
<p> Change cluster to: </p>
<select class="form-control" name='kvalue' id="kvalue" value=''>
<option value=2>2</option>
<option value=3>3</option>
<option value=4>4</option>
<option value=5>5</option>
<option value=6>6</option>
<option value=7>7</option>
<option value=8>8</option>
<option value=9>9</option>
<option value=10>10</option>
</select>
<a class='btn btn-default' href='/survey//results'>Clusterize!</a>
</div>
.. and use it as the 'k' value in this node.js routes file:
async function renderViewResults (req, res, next) {
const { id } = req.params;
try {
let { survey, questions } = await fetchSurveyInfo(id);
const responses = await Response.find({ surveyId: survey._id });
const userResponse = responses.filter(res => res.userId.toString() === req.user._id.toString())[0];
const userAnswerSequence = !isNil(userResponse);
if (userResponse) {
questions = questions.sort((a, b) => {
return userResponse.answerSequence.indexOf(a) - userResponse.answerSequence.indexOf(b);
});
}
const k = 4;
const vectors = kmeans.vectorizeResponses(responses);
const cluster = await kmeans.clusterize({ vectors, k });
Any help on how I should go about doing this would be greatly appreciated!
via derekwb91
No comments:
Post a Comment