I’m venturing slightly further than normal with repeats and arrays, etc. but need a steer from someone.
Here’s my page code:
<div class="container">
<form id="formQuestionnaire" is="dmx-serverconnect-form" method="post" action="/dmxConnect/api/AddEditQuestionnaire.php">
<div is="dmx-repeat" id="repeatquestions" dmx-bind:repeat="connQuestions.data.queryQuestions">
<div class="form-row">
<div class="col">
<h4 class="mt-3">{{$index + 1}}. {{questionText}}</h4>
<select dmx-bind:id="response{{$index}}" name="response[]" class="custom-select mb-2">
<option value="answered">See answer</option>
<option value="na">Not applicable</option>
<option value="rathernotsay">Would rather not say</option>
</select>
<div dmx-show="(response.value == 'answered')">
<input type="range" class="form-range" dmx-bind:id="customRange_{{$index}}" name="scalevalue[]" min="0" max="10" style="width: 50%;"> <span class="ml-3" style="font-size: 2em;">{{scalevalue.value}}</span>
<input type="hidden" dmx-bind:id="questionid_{{$index}}" name="questionid[]" dmx-bind:value="QuestionID">
<textarea dmx-bind:id="comments_{{$index}}" name="comments[]" class="form-control" placeholder="Comments"></textarea>
</div>
</div>
</div>
</div>
<div class="form-row mt-2 mb-2">
<div class="col">
<button id="btn1" class="btn btn-primary" type="submit">Submit</button>
</div>
</div>
</form>
</div>
But I don’t think I’ve got it right. I have a table containing loads of questions and the page has a query to get a relevant batch of those questions so they can be answered. So I will end up sending the question ID and the answer fields to my API script which will then repeat through them and insert/update the database.
Am I on the right track? Could someone just confirm I’m doing this right or correct me if I’m wrong?
Many thanks all.
Community Page
Last updated:
Last updated: