0

Hi I'm still learning to be good in php programming, I has been find for the solution to my problem about a day but still can't solve it. The problem is stated below.

I'm using laravel framework for this project, I would like to send different emails to different recipients and my way to do it is using a page with loop a form like below enter image description here

  <script>
    //auto submit form
    document.getElementById('sendemail').submit(); // SUBMIT FORM
  </script>
@foreach ($users as $user)

<?php
$count_emps += count($user->id);
for($i=0; $i<=$count_emps; $i++){
  }
?>

  <form id = "sendemail" class = "form-horizontal" role = "form" method = "POST" action = "{{ url('/tms/sendemail/send') }}">
  {!! csrf_field() !!}
    <div class = "container">
      <label for = "receiver">To: </label>
      <input id = "count" type = "text" name = "count" value = "{{ $i }}" class = "form-control">
      <input id = "receiver" type = "text" name = "receiver" value = "{{ $user->id }}" class = "form-control">
      <input type = "submit" value = "Send">
    </div>
  </form>


@endforeach

The problem now is I'm out of the way to let each of the form run so that I get 3 different email from the form shown. Please help and thank you.

Yap Wayne
  • 19
  • 5
  • You need to submit all the forms use only one submit button . Correct ? – Al-Mustafa Azhari Mar 18 '18 at 14:50
  • except for this do you have any solution that can send these 3 'loop' form without using submit button? – Yap Wayne Mar 18 '18 at 14:52
  • You will use a button but not submit button and with JavaScript you can submit all those 3 forms . Check the soluation of @James Johnson on [Submit two forms with one button](https://stackoverflow.com/questions/7843355/submit-two-forms-with-one-button) – Al-Mustafa Azhari Mar 18 '18 at 14:56
  • that function I try before but cannot because I don't know how to put the increase value into javascript and I'm using auto trigger submit button – Yap Wayne Mar 18 '18 at 15:03
  • You can named the forms like `sendemail_{ $i }` and send the "$count_emps" to Javascript function then you can create for loop in Javascrips to submit all the forms with id `"sendemail_"+i` – Al-Mustafa Azhari Mar 18 '18 at 15:14

0 Answers0