du31992 2013-08-18 06:18 采纳率: 0%
浏览 27

在php循环中调用jquery

I am new to php,jquery and json. I am using all of it in my new website. My problem is i need to divide my html page into 4 parts as divs(north,south,east,west) and display a pie chart in each div, drawn from a jquery/javascript. I have added a foreach loop for each zone like north,south,east,west. and i have set the data needed by jquery/php script in session.

But i see that script executes only at the end of for loop and draws the pie chart only in the fourth div.

I want to know the syntax of how i can invoke the script for every iteration of the php loop. Request your help.

          <?php
    $customerSelected = "IBL";//change this to actual selected customer
    $zoneArray = array(1,2,3,4);
    $_SESSION['customerSelected']=$customerSelected;    
    foreach($zoneArray as $zone){

        $_SESSION['zone']=$zone;    

        $quadrantName = '';
        if($zone == 1){
            $quadrantName = 'firstQuadrantNorth';
        }else if($zone == 2){
            $quadrantName = 'secondQuadrantSouth';
        }else if($zone == 3){
            $quadrantName = 'thirdQuadrantEast';                
        }else if($zone == 4){
            $quadrantName = 'fouthQuadrantWest';

        }
        $_SESSION['quadrant']=$quadrantName;
    ?>
    <div id="<?=$zone?>" style="height:250px;width:49.7%;float:left;      border:1px   solid #CCC;">

        <div id="<?=$quadrantName?>" style="min-width:50%; height:100px;text-align:left"></div>
        <script src="scripts/piechartsims.js?v=<?=$cachebuster; ?>"></script>
        <div style="min-width:50%;height:140px;text-align:center;align:center;overflow:auto;">

            <?php
                include('LastCommunicatedInc.php');   
            ?>
        </div>
    </div>
    <?php
    }
    ?>

`

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度