简体   繁体   中英

Send Multiple Radio Button Value to Controller Codeigniter

I have survey page containing multiple question and radio button for each question

 <table class="table">
 <form action="What should i write here" method="post">
     <?php $numbering = 1;
        foreach ($dataQuestion as $key => $value) : ?>
         <tr>
             <td width="1%"><?= $numbering++; ?></td>
             <td><?= $value->question ?>
                 <div class="form-check mt-1">
                     <input class="form-check-input" type="radio" name="indikator[$value->id]" value="1">
                     Very Good
                     <br>
                     <input class="form-check-input" type="radio" name="indikator[$value->id]" value="2">
                     Good
                     <br>
                     <input class="form-check-input" type="radio" name="indikator[$value->id]" value="3">
                     Decent
                     <br>
                     <input class="form-check-input" type="radio" name="indikator[$value->id]" value="4">
                     Bad
                     <br>
                     <input class="form-check-input" type="radio" name="indikator[$value->id]" value="5">
                     Very Bad
                 </div>
             </td>
         </tr>
     <?php endforeach; ?>
     <tr>
         <td colspan="2"><button type="submit" class="btn btn-info btn-lg btn-block">Submit</button></td>
     </tr>
 </form>

I'm trying to pass selected radio button value to my controller file using <form action=""> but every question have different answer, how to send array of all answered question to my controller via <form action=""> ?

It seems everyone prefer to use javascript, url, and form_radio() . Any help would be appreciated, thank you.

<form action="What should i write here" ...>


Write there the route/path meant to receive your HTTP POST request. Ie:

<form action="/survey" method="post">

The state a route definition meant to receive the route in app\Config\Routes.php . Ie:

// ...
$routes->post("/survey", "SurveyController::create");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM