Jump to content

How to get selected radio button value in .tpl file


Tje123

Recommended Posts

I'm developing carrier module for my prestashop project.i have loaded week days from my db table for user to select.

 

what i'm trying to do :

 

when user select a day,i want to show time ranges for that day.

 

  **DeliveryWeek.php class**

 

    public function getweekday(){

      $dbQuery = new DbQueryCore();

         $dbQuery->select('*');

         $dbQuery->from('delivery_weeks', 'c');

         $result = Db::getInstance(_PS_USE_SQL_SLAVE_)

             ->executeS($dbQuery);

         return $result;

    }

 

**delivery_scheduler.php**

 

 

    public function hookDisplayCarrierExtraContent()

        {

            global $smarty;

            include_once(_PS_MODULE_DIR_.'delivery_scheduler/classes/DeliveryWeek.php');

            $DeliveryWeek=new DeliveryWeek();

    

            $resul=$DeliveryWeek->getweekday();

            foreach ($resul as $res) {

              $var[]=$res['weekday'];

            }

            $this->smarty->assign(array('WeekVal' => $resul));

            return $this->display(__FILE__, 'views/templates/front/calendar.tpl');

    

        }

 

**calendar.tpl**

 

      <div class="block_content">

        <p>

          {foreach $WeekVal as $item}

    

             <input type="radio" name="id_gender" id="{$item.id_zm_delivery_week}" value="{$item.weekday}" />

             <label for="{$item.id_delivery_week}" class="top">{$item.weekday}</label></br>

    

             {/foreach}

        </p>

      </div>

 

 

**delivery_weeks table**

 

    +---------------------+-----------+--------------+--------------+--------------------------+--------------------------+--------------------------+

    | id_delivery_week | weekday   | availability | default_cost | specific_time_cost_1     | specific_time_cost_2     | specific_time_cost_3     |

    +---------------------+-----------+--------------+--------------+--------------------------+--------------------------+--------------------------+

    |                   1 | Sunday    |            0 | 150.00       | 06:00:00-10:00:00-100.00 | 10:00:00-18:00:00-120.00 | 18:00:00-22:00:00-150.00 |

    |                   2 | Monday    |            1 | 150.00       | 06:00:00-10:00:00-100.00 |                          | 18:00:00-22:00:00-150.00 |

    |                   3 | Tuesday   |            1 | 150.00       | 06:00:00-10:00:00-100.00 |                          | 18:00:00-22:00:00-150.00 |

    |                   4 | Wednesday |            1 | 150.00       | 06:00:00-10:00:00-100.00 |                          | 18:00:00-22:00:00-150.00 |

    |                   5 | Thursday  |            1 | 150.00       | 06:00:00-10:00:00-100.00 |                          | 18:00:00-22:00:00-150.00 |

    |                   6 | Friday    |            1 | 150.00       | 06:00:00-10:00:00-100.00 |                          | 18:00:00-22:00:00-150.00 |

    |                   7 | Saturday  |            1 | 150.00       | 06:00:00-10:00:00-100.00 | 10:00:00-18:00:00-120.00 | 18:00:00-22:00:00-150.00 |

    +---------------------+-----------+--------------+--------------+--------------------------+--------------------------+--------------------------+

 

 

 

 

 

post-1441108-0-39671300-1508388129_thumb.jpeg

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...