0

This is my code :

@php
   $id = 1;
@endphp

<form action="{{route('upload.submit_rencana_kerja_bulanan',$id)}}" method="post">
{{ csrf_field() }}
<!-- Begin body content -->
<div class="card-body">
    {{-- TABLE --}}
    <!-- Begin body content -->
    <div class="table-responsive">
        <table data-toggle="table" data-height="460" data-width="600" data-search="true" data-visible-search="true" data-show-columns="true"
            data-show-footer="false">
            <thead>
                <tr>
                    <th data-sortable="true">Nomor</th>
                    <th data-sortable="true">ID</th>
                    <th data-sortable="true">Customer</th>
                    <th data-sortable="true">Outlet</th>

                    <th>Action</th>
                </tr>
            </thead>
            <tbody>
                @foreach ($masterCustomer as $masterCustomers)
                    <tr>
                        <td>{{$nomorTable2}}</td>
                        <td>{{$masterCustomers->id}}</td>
                        <td>{{$masterCustomers->customer_name}}</td>
                        <td>{{$masterCustomers->customer_outlet}}</td>

                        <td class="text-center">
                            <a href="{{url('add_customer/'. $masterCustomers->id . '/' . $emp_name . '/' . $date . '/rencana_kerja_bulanan')}}">
                                <button class="btn btn-success" type="submit">
                                    Add
                                </button>
                            </a>
                        </td>
                    </tr>

                    @php
                        $nomorTable2++;
                    @endphp
                @endforeach

            </tbody>
        </table>
    <!-- end of body content -->
    </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>

                {{-- <button id="btnsubmit" class="btn btn-success" type="submit">
                    Submit Data
                </button> --}}
            </div>
        </div>
        </div>
    </div>
    {{-- SAMPAI SINI MODALNYA --}}
</div>
</form>

i'm want to change the $id = 1; value to what user will choose in the table after clicking the button form the table

can you change the value by this method?

cant add more code , because stackoverflow not allowing me to do that , to much code it said

3
  • You need to do the manipulation with javascript. PHP is a server side scipt, unless the user submits the form and send it back to the server, PHP cant change anything on the page from the moment it arrives on your screen (client side). Commented Oct 14, 2020 at 8:07
  • Can you explain more about it Commented Oct 14, 2020 at 8:08
  • PHP is a server side language while Javascript runs in client. That means they both run separately. But if you would like them to process together, such as getting data to be displayed using javascript, you will have to use AJAX Commented Oct 14, 2020 at 8:27

1 Answer 1

2

You can't change the PHP value using javascript. I think you can take a hidden field in the form and change the value of hidden field on click the button. When form will be post you can get value of the id from that hidden field.

Sign up to request clarification or add additional context in comments.

2 Comments

solve thanks , i love when my code become more stupid but work XD
That's nice to hear. Great job.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.