doujun7161 2015-06-27 20:59
浏览 62

使用smarty模板,php和sql&javascript的动态输出

These are my files:

show_booking_career_list.tpl

<form action="" method="post" name="searching_form" id="searching_form">
  <input type="hidden" name="sel_from_country" value="{$select_from}" />
  <input type="hidden" name="sel_to_country" value="{$select_to}" />
  <input type="hidden" name="parcel_booking_weight" value="{$select_weight}" />
  <input type="hidden" name="sel_booking_height" value="{$select_height}" />
  <input type="hidden" name="sel_booking_width" value="{$select_width}" />
  <input type="hidden" name="sel_booking_length" value="{$select_girth}" />
  <input type="hidden" name="search_service_id" id="search_service_id" value="{$search_service_id}" />

  <!--==zip code==-->
  <input type="hidden" name="sel_from_zipcode" value="{$smarty.session.sel_from_zipcode}" />
  <input type="hidden" name="sel_to_zipcode" value="{$smarty.session.sel_to_zipcode}" />
  <input type="hidden" name="sel_booking_type" value="{$smarty.session.sel_booking_type}" />

  <input type="hidden" name="post_booking_data" id="post_booking_data" value="submit" />
  <div id="">
    <div class="container " >
      <div class="row"> 
        {$functions->getPackageSerachingServiceLinks()}

{section name=data loop=$servicedata_searching} <a  onclick="seachingServiceValuePut({$servicedata_searching[data].sid})"   class="href_pointer">
        <div class="col-md-2 col-lg-2 col-sm-6 col-xs-6 center">
        {if $search_service_id==''}
          <div class="{if $servicedata_searching[data].sid==4}packbg1_active{else}packbg1{/if} padding5 border_radius5">
        {else}
          <div class="{if $servicedata_searching[data].sid==$search_service_id}packbg1_active{else}packbg1{/if} padding5 border_radius5">
        {/if}   
            <h4 class="white">{$servicedata_searching[data].sname}</h4>
            <p class="pink"><strong>
            From ${$functions->getMinimumValueParcelPackage($servicedata_searching[data].sid,$select_from,$select_to,$select_weight,$select_height,$select_width,$select_girth)}

            </strong></p>
          </div>
            <div>&nbsp;</div>
        </div>
        </a> {/section}</div></div> 

function.php

   //===========================package searching service links================================//       
    function getPackageSerachingServiceLinks()
    {
        global $objSmarty;
        $select_query="select sid,sname from pb_services where deleted='N' and status='Y' order by FIELD(sid, 4,1,2,3)";
        $servicedata_searching=$this->dbh->FetchAllResults($select_query);
        $objSmarty->assign("servicedata_searching", $servicedata_searching);
    }

ajax.js

    function seachingServiceValuePut(sel_value)
{

    document.getElementById('search_service_id').value=sel_value;
    document.getElementById('searching_form').submit();
}

sql file

 INSERT INTO `pb_services` (`sid`, `sname`, `sort_description`, `description`, `status`, `deleted`) VALUES
(1, 'Next Day Delivery', 'Next Day Deliverys', '<p>3+ Day Delivery</a></p>', 'Y', 'N'),
(2, '2 Day Delivery', '2 Day Delivery', '<p>3+ Day Delivery</a></p>', 'Y', 'N'),
(3, '3+ Day Delivery', '3+ Day Delivery', '<p>2 Days&nbsp;</p>', 'Y', 'N'),
(4, 'Same Day Delivery', '', 'same day', 'Y', 'N');


INSERT INTO `set_delivery_package_details` (`pac_id`, `unique_id`, `title`, `career_id`, `service_id`, `start_weight_range`, `end_weight_range`, `set_price`, `sel_countrys`, `dimesion_height`, `dimesion_width`, `dimesion_girth`, `dimesion_weight`, `service_type`, `delivery_within`, `collactions_made`, `fully_trackble`, `prienter_required`, `compensation`, `description`, `career_service_image_path`, `9am_delivery_charge`, `10am_delivery_charge`, `11am_delivery_charge`, `12am_delivery_charge`, `entry_date`, `from_time`, `to_time`, `status`, `deleted`) VALUES
(1, 'AAADLL', 'testing', 11, 1, '0', '1', '5', '94,222', '10', '10', '10', '300', 'L_D_O', '', '', 'Y', 'Y', '', '', '', '', '', '', '', '2015-06-20', '', '', 'Y', 'N'),
(2, 'AAADLL', 'testing', 11, 1, '2', '20', '10', '94,222', '10', '10', '10', '300', 'L_D_O', '', '', 'Y', 'Y', '', '', '', '', '', '', '', '2015-06-20', '', '', 'Y', 'N'),
(3, 'AAADLL', 'testing', 11, 1, '21', '50', '20', '94,222', '10', '10', '10', '300', 'L_D_O', '', '', 'Y', 'Y', '', '', '', '', '', '', '', '2015-06-20', '', '', 'Y', 'N'),
(4, 'AAADLL', 'testing', 11, 1, '51', '300', '30', '94,222', '10', '10', '10', '300', 'L_D_O', '', '', 'Y', 'Y', '', '', '', '', '', '', '', '2015-06-20', '', '', 'Y', 'N'),
(5, 'AAADLL', 'testing', 11, 1, '300', 'FLAT', '50', '94,222', '10', '10', '10', '300', 'L_D_O', '', '', 'Y', 'Y', '', '', '', '', '', '', '', '2015-06-20', '', '', 'Y', 'N'),
(6, 'IAVHUW', '23-6-2015', 11, 1, '0', '1', '5', '94,222', '20', '20', '20', '50', 'L_D_O', '2 days', '', 'Y', 'Y', 'this is info for compensation', '<p>Test description there.</p>', '', '10', '5', '5', '5', '2015-06-23', '01:00', '13:59', 'Y', 'N'),
(7, 'IAVHUW', '23-6-2015', 11, 1, '2', '20', '10', '94,222', '20', '20', '20', '50', 'L_D_O', '2 days', '', 'Y', 'Y', 'this is info for compensation', '<p>Test description there.</p>', '', '10', '5', '5', '5', '2015-06-23', '01:00', '13:59', 'Y', 'N'),
(8, 'IAVHUW', '23-6-2015', 11, 1, '21', '50', '10', '94,222', '20', '20', '20', '50', 'L_D_O', '2 days', '', 'Y', 'Y', 'this is info for compensation', '<p>Test description there.</p>', '', '10', '5', '5', '5', '2015-06-23', '01:00', '13:59', 'Y', 'N'),
(9, 'IAVHUW', '23-6-2015', 11, 1, '51', '300', '20', '94,222', '20', '20', '20', '50', 'L_D_O', '2 days', '', 'Y', 'Y', 'this is info for compensation', '<p>Test description there.</p>', '', '10', '5', '5', '5', '2015-06-23', '01:00', '13:59', 'Y', 'N'),
(10, 'IAVHUW', '23-6-2015', 11, 1, '300', 'FLAT', '25', '94,222', '20', '20', '20', '50', 'L_D_O', '2 days', '', 'Y', 'Y', 'this is info for compensation', '<p>Test description there.</p>', '', '10', '5', '5', '5', '2015-06-23', '01:00', '13:59', 'Y', 'N'),
(11, 'AFQCXL', '23 June 2015', 11, 1, '0', '1', '2', '94,222', '10', '10', '10', '15', 'L_D_O', '2', '', 'Y', 'Y', 'Info for comper', '<p>the desctripton</p>', '', '2', '5', '5', '10', '2015-06-23', '14:05', '17:02', 'Y', 'N'),
(12, 'AFQCXL', '23 June 2015', 11, 1, '2', '20', '4', '94,222', '10', '10', '10', '15', 'L_D_O', '2', '', 'Y', 'Y', 'Info for comper', '<p>the desctripton</p>', '', '2', '5', '5', '10', '2015-06-23', '14:05', '17:02', 'Y', 'N'),
(13, 'AFQCXL', '23 June 2015', 11, 1, '21', '50', '8', '94,222', '10', '10', '10', '15', 'L_D_O', '2', '', 'Y', 'Y', 'Info for comper', '<p>the desctripton</p>', '', '2', '5', '5', '10', '2015-06-23', '14:05', '17:02', 'Y', 'N'),
(14, 'AFQCXL', '23 June 2015', 11, 1, '51', '300', '10', '94,222', '10', '10', '10', '15', 'L_D_O', '2', '', 'Y', 'Y', 'Info for comper', '<p>the desctripton</p>', '', '2', '5', '5', '10', '2015-06-23', '14:05', '17:02', 'Y', 'N'),
(15, 'AFQCXL', '23 June 2015', 11, 1, '300', 'FLAT', '12', '94,222', '10', '10', '10', '15', 'L_D_O', '2', '', 'Y', 'Y', 'Info for comper', '<p>the desctripton</p>', '', '2', '5', '5', '10', '2015-06-23', '14:05', '17:02', 'Y', 'N');

I have four sections: same day delivery, next day delivery, 2+days delivery , 3+ days delivery. i want to activate the section which has entries and deactivate the section which have no entries. i am getting all the outputs correctly but when suppose same day delivery has no entries, it still remain activated and i have to click manually to see other sections.

here the screenshots:

this is the problem:

this is the problem

this how it should be

this how it should be

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 MATLAB动图问题
    • ¥15 【提问】基于Invest的水源涵养
    • ¥20 微信网友居然可以通过vx号找到我绑的手机号
    • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
    • ¥15 解riccati方程组
    • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名
    • ¥65 汇编语言除法溢出问题