Assign query results on client side

I would like some advice how to best approach a relative simple challenge.

I have a table like this:

+------------+----------+
| QuestionID |  Answer  |
+------------+----------+
|          1 | Answer 1 |
|          2 | Answer 2 |
|          3 | Answer 3 |
+------------+----------+

I load this on client side by using a serverconnect named "get_answers".

Then I am displaying these in inputs by using the index [0], [1], etc. of the query:

<input type="text" dmx-bind:value="get_answers.data.query1[0].Answer">
<input type="text" dmx-bind:value="get_answers.data.query1[1].Answer">
etc.

However, when one question is skipped, for example QuestionID 2 is not filled out, the wrong answer will be listed.

Is there a way to bind the answers based on the QuestionID column?

Something along the lines of:

Answer 1=<input type="text" dmx-bind:value="get_answers.data.query1.Answer where QuestionID=1">
Answer 2=<input type="text" dmx-bind:value="get_answers.data.query1.Answer where QuestionID=2">

I'd rather not use GET on the server side, so ideally do some sort of assignment on the client side.

Is this possible?

you can repeat the array get_answers.
inside the repeat have input box with value:
get_answers.data.query1.where(`QuestionID`, $index+1, '==')[0].values(`Answer`)

1 Like

I think that Data Traversal will help you. Unfortunately it is not documented for Wappler. However, our old friend DMXZone can come to the rescue.

1 Like

Thanks, that works!
Made a small modification (otherwise it posts both the Answer and the QuestionID + also removed the repeater):

<input dmx-bind:value="get_answers.data.query1.where('QuestionID', 1, '==')[0].Answer)">

Thanks for the suggestion @ben, that works too and looks like a very powerful module.