0

On the page for drawing the values, after entering the values into different fields, only the last ones are passed on.

There should be e.g.: for values v1, v2, v3, v4, v5 and groups g1, g2 the example result should be g1: v1, v3; g2: v2, v4, v5.

Actually it is: g2: v5 from the above example.

Where do I make a mistake? I'm very beginner, so there may be unintentional errors in the code. Here's my code.

Entering values. New fields appear when the button is pressed.

<div class="mx-auto position-relative form-wrapper">
            <form method="post" id="form" action="{{route('randomizeValues.store')}}" name="form" class="form text-center"
                data-response-message-animation="slide-in-left" novalidate>
                @csrf
                <div id="parent" class="list-group">
                    <div class="form-group form-filed horizontal">
                        <input name="values" class="input" type="text" autocomplete="off" placeholder="Enter value"
                            autofocus onkeypress='validate(event)' onkeydown="pressEnter(event)" required>
                    </div>
                </div>
                <div id="parent" class="list-group">
                    <div class="form-group form-filed horizontal">
                        <input name="groups" class="input" type="text" autocomplete="off" placeholder="Enter group"
                            autofocus onkeypress='validate(event)' onkeydown="pressEnter(event)" required>
                    </div>
                </div>
                <button type="submit" class="btn btn-lg btn-alternate align-center">Draw</button>

Display the results in tables.

<div class="section-heading text-center">
                <h2>The following groups of results were drawn:</h2>
                @foreach ($values_json as $value => $val)
                <table class="table table-responsive">
                    <thead>
                        <tr>
                            <th style="width: 16.66%" scope="col">{{$value}}</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach($val as $v)
                        <td> {{$v}}
                            {{$loop->last? "": "  &nbsp; " }} </td>
                        @endforeach
                    </tbody>
                </table>
                @endforeach
                <form method="post" id="form" action="{{route('randomizeValue.store')}}" name="form"
                    class="form text-center" data-response-message-animation="slide-in-left" novalidate>
                    @csrf
                    <button type="submit" class="btn btn-lg btn-alternate align-center">Draw again</button>
                    <a href="/randomizeValue" id="destroySession" type="submit"
                        class="btn btn-lg btn-alternate align-center">Cancel</a>
                </form>
            </div>
                </form>
            </div>
j.sadne
  • 39
  • 5

3 Answers3

0

You're forgetting to put things in <tbody> in a row. Simply add <tr></tr> next to the <td>'s.

                <tbody>
                    @foreach($val as $v)
                    <tr>
                        <td> {{$v}} {{$loop->last? "": "  &nbsp; " }} </td>
                    </tr>
                    @endforeach
                </tbody>
GreenPepper
  • 138
  • 2
  • 11
0

try this

     <div class="section-heading text-center">
            <h2>The following groups of results were drawn:</h2>
           
            <table class="table table-responsive">
                <thead>
                    <tr>
                        <th style="width: 16.66%" scope="col">{{$value}}</th>
                    </tr>
                </thead>
                <tbody>
                  @foreach ($values_json as $value => $val)
                      @foreach($val as $v)
                         <td> {{$v}} {{$loop->last? "": "  &nbsp; " }} </td>
                      @endforeach
                  @endforeach 
                </tbody>
            </table>
           
Yahya Alezzi
  • 134
  • 6
0

It looks like you have nested forms, which is a no-no unless you use JS to handle the submission.

I suggest you get the second form out of the first one and try that way. You can read more about the form element here: https://html.spec.whatwg.org/multipage/forms.html#the-form-element

Or read the discussion here: https://stackoverflow.com/a/379622/2671523

Aleks.P
  • 64
  • 5