Insert Single Choice as last column into a table

deivodeivo Berne, SwitzerlandCommunity Member Qubie ✭

Insert Single Choice as last column into a table

Dear all

I'd like to create a table in which participants can enter their choice in the last column as shown in the image below.

I already tried to do it with "Hot Spot" by inserting the table as an image and define the boxes in last column as a field to enter a decision. However, the problem is that although I customize validation to 1, participants can still click on more than one hot spot. Thus to have a single choice in the last column would be the best!

I am very thankful for any suggestions and ideas!


Best Answer

  • ahmedAahmedA IndiaCommunity Member Wizard ✭✭✭✭✭
    edited February 3 Accepted Answer

    You could make the choices of a multiple choice question into table rows and then use JS to move the radio buttons into the desired cell. Here's the demo for the code below:

    Question HTML:

                table, th, td {
                    border: 2px solid black;
                    border-collapse: collapse;
                table {
                    width: 100%;
                th, td {
                    padding: 5px;
                    text-align: center;
                    width: 20%;
            Please make your choice

    Choices (Entered through edit multiple):

    <table> <tr> <th>Choice</th> <th>Investment</th> <th>Remaining Balance</th> <th>Number of Shares</th> <th>Your Decision</th> </tr> </table>
    <table> <tr> <td>Choice 1</td> <td>$ 2</td> <td>$ 0</td> <td>10</td> <td></td> </tr> </table>
    <table> <tr> <td>Choice 2</td> <td>$ 1.5</td> <td>$ 0.5</td> <td>9</td> <td></td> </tr> </table>

    Question JS:

    Qualtrics.SurveyEngine.addOnReady(function () {
    	let all_inputs = this.getQuestionContainer().querySelector("ul").querySelectorAll(".q-radio");
    	let all_rows = this.getQuestionContainer().querySelector("ul").querySelectorAll("tr");
    	for (i = 1; i < all_inputs.length; i++) {
            all_inputs[i].style.float = "none";
            all_inputs[i].style.verticalAlign = "middle";


  • deivodeivo Berne, SwitzerlandCommunity Member Qubie ✭

    @ahmedA Thank you very much for your help :-) Your demo looks fantastic!

    I managed your code to have a proper table, but somehow I could move the radio buttons into the desired cell.

    Although I tried to implement your code as you suggested.

    Where is my mistake?

    And looks the table also the same for the mobile view as for the computer view?

    Thank you very much and all the best!

  • ahmedAahmedA IndiaCommunity Member Wizard ✭✭✭✭✭

    It appears that you have inserted the code properly, so the error must lie elsewhere. Can you check if you are getting any errors in the console (If you haven't used the console before, you'll find resources related to your browser online).

    Are you using a multiple choice single answer question with horizontal choices? If not, then you'll need to switch to it. It could also be related to the theme, I use the boxed question theme available in the old look and feel editor.

    See if any of these solve your problem.

Sign In to Comment