1

I'm doing a display page which display data from a table and there are 3 checkbox which user can check to represents as their choice.

<tbody>@foreach($data as $d)
<?php $choice = 0 ?>
<tr>
   <td>{{$d->domain_label}}{{$d->domain_extension}}</td>
   <td>{{$d->domain_reg_date}}</td>
   <td><input type="checkbox" name="choice[]" value="R"></td>
   <td><input type="checkbox" name="choice[]" value="D"></td>
   <td><input type="checkbox" name="choice[]" value="H"></td>
   <td><a href="{{ URL::to('/postvalid2/'.$d->domain_label.'/'.$d->domain_extension)}}"><button class="btn btn-success btn-xs" type="submit">Select</button></a></td>
    </tr>@endforeach

i've tried using form to display the value for checkbox and it's working. the problem with button is i cannot bring the correct value of domain_label and domain_extension through action.

5
  • If you try with form, then why you need to use button? Commented Apr 18, 2017 at 7:25
  • i deleted what i did with the form. coding above is the product when i decide not to use form. Commented Apr 18, 2017 at 7:27
  • You can then use jquery to bring value from checkboxes to controller Commented Apr 18, 2017 at 8:02
  • can you show me the example on how to call the variable from jquery in controller ? Commented Apr 18, 2017 at 8:14
  • Maybe this helps you: <br /> stackoverflow.com/questions/16170828/… Commented Apr 18, 2017 at 9:40

1 Answer 1

1

You may use inputs with type hidden to send hidden data to controller

<input type="hidden" name="domain_label[<?=$d->id?>]" value="<?=$d->domain_label?>">
<input type="hidden" name="domain_extension[<?=$d->id?>]" value="<?=$d->domain_extension?>">
Sign up to request clarification or add additional context in comments.

7 Comments

i did. But it will bring the latest data. Like what i did above, i did a foreach which means there will be many data. So the form will detect the latest value of both domain_label and domain_extension. Thats why i decided not to use form
set name to domain_label[<?=$d->id?>] and you will get the array with all data. see updated answer.
if i did an increment of i and assigned it as the id, would it work the same ? Because the table didnt have any unique id.
You may use increment. Or open new form in each table's row, so submit button will only submit it's form.
can we do tht ? I alrdy searched for and it says you cannot put for inside a table's part.
|

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.