php - 当到达 javascript 中的 php 标签时,我的网页停止加载

标签 php javascript

我遇到了一个以前在其他网站上从未遇到过的网站问题,这可能很简单,但似乎无法解决。请查看并提出建议。

<!--All Header Elements-->
<?php 
$pageName = "Easy-Quote";
$siteName = "Bloemendal";
include("../Includes/header_non_index.inc"); 
include("../Includes/function12.inc"); 
?> <?php error_reporting (E_ALL ^ E_NOTICE); ?>
<!--All Header Elements-->
<body>
<script type="text/javascript">

var total = 0;

var allVenues = "";
var allVenuePricing = "";
var allTents = "";
var allTentPricing = "";
var allDFPricing = "";
var allMenus = "";
var allMenuPricing = "";
var allSF = "";

var venueName = "";
var venuePrice = 0;
var tentName = "";
var tentPrice = 0;
var DF = "";
var DFPrice = 0;
var menuName = "";
var menuPrice = 0;
var serviceFee = 0;

var getGuests = null;
var totalField = null;
var venueField = null;
var tentField = null;
var DFField = null;
var menuField = null;

//Get Fields
function getFields()
{
     getGuests = document.getElementById('Guests');
     totalField = document.getElementById('TotalField');
     depositField = document.getElementById('DepositField');
     venueField = document.getElementById('getValue');
     tentField = document.getElementById('getTent');
     DFField = document.getElementById('getDF');
     menuField = document.getElementById('getMenu');
     serviceField = document.getElementById('getServiceCharge');
}

function convertAllArrays()
{
    <?php
    $allVenues=getVenues(); 
    $allVenuePricing=getVenuePricing();
    $allTents=getTents(); 
    $allTentPricing=getTentPricing();
    $allDFPricing=getDFPricing();
    $allMenus=getMenus(); 
    $allMenuPricing=getMenuPricing();
    $allSF=getServiceFee(); 

    //##################Declaring All Arrays###########################\\
        echo "allVenues = ". json_encode($allVenues) . ";\n"; //All the Venue Names
        echo "allVenuePricing = ". json_encode($allVenuePricing) . ";\n"; //All the Venue Pricing
        echo "allTents = ". json_encode($allTents) . ";\n"; //All the Tent Names
        echo "allTentPricing = ". json_encode($allTentPricing) . ";\n"; //All the Tent Pricing 
        echo "allDFPricing = ". json_encode($allDFPricing) . ";\n"; //All the Dance Floors
        echo "allMenus = ". json_encode($allMenus) . ";\n"; //All the Menu Names
        echo "allMenuPricing = ". json_encode($allMenuPricing) . ";\n"; //All the Menu Pricing
        echo "allSF = ". json_encode($allSF) . ";\n"; //All the Service Fees
    ?>
}

function activeControl()
{

    //Check Venue Field
    if(getGuests.value > 0)
    {
        venueField.disabled = false;
    }else{
        venueField.options[0].selected = true;
        venuePrice = 0;
        venueName = "";
        venueField.disabled = true; 
    }

    //Check Tent Field
    if(venueField.selectedIndex == 1)
    {
        tentField.disabled = false;
    }else{  
        tentPrice = 0;
        tentName = "";
        tentField.options[1].selected = true;
        tentField.disabled = true;
    }

    //Check Menu Field
    if(venueField.selectedIndex > 0)
    {
        menuField.disabled = false;
    }else{
        menuPrice = 0;
        menuName = "";
        menuField.options[0].selected = true;
        menuField.disabled = true;  
    }

    //Check Dance Floor Field
    if(venueField.selectedIndex == 1)
    {
        DFField.disabled = false;
    }else{
        DFField.checked = false;
        DF = "No";
        DFPrice = 0;
        DFField.disabled = true;    

    }

    updateTotal();
}

function updateTotal()
{   

    //Get Venue Details 
    var getSelectedVenue = venueField.selectedIndex;
    if(getSelectedVenue > 0)
    {
        venueName = allVenues[getSelectedVenue];
        venuePrice = allVenuePricing[getSelectedVenue]
    }

    //Get Tent Details  
    var getSelectedTent = tentField.selectedIndex;
    if(getSelectedTent > 1)
    {
        tentName = allTents[getSelectedTent-1];
        tentPrice = allTentPricing[getSelectedTent-1]
    }else if(getSelectedTent == 1)
    {
        tentName = "";
        tentPrice = 0;
    }

    //Get DF Details    
    if(DFField.checked)
    {
        DF = "Yes";
        DFPrice = allDFPricing[1];
    }else
    {
        DF = "No";
        DFPrice = 0;
    }

    //Get Menu Details  
    var getSelectedMenu = menuField.selectedIndex;
    if(getSelectedMenu > 0)
    {
        menuName = allMenus[getSelectedMenu];
        menuPrice = allMenuPricing[getSelectedMenu]
    }

    //Get Service Fee Details   
    var getSelectedSF =serviceField.selectedIndex;
    if(getSelectedSF > 0)
    {
        serviceFee = allSF[getSelectedSF];
    }

    venuePrice = parseFloat(venuePrice,10);
    tentPrice = parseFloat(tentPrice,10);
    DFPrice = parseFloat(DFPrice,10);
    menuPrice = parseFloat(menuPrice,10);
    serviceFee = parseFloat(serviceFee,10);


    //Update Total Field
    total = venuePrice + tentPrice +DFPrice + (menuPrice*getGuests.value);
    total = total + (total*serviceFee);
    totalField.value = "R"+total;

    //Update Deposit Fee
    depositField.value = "R"+(total*0.3);
}



</script>
<!--Global Elements-->

那是网站的前 196 行。离线加载,但是当上传到网络服务器时,它最多只能上传:

function convertAllArrays()
{

PS:我知道在 javascript 中调用 php 变量并不理想,但它应该足以满足我的目的。

!!编辑!!
网址链接:http://bloemendal.co.za/Easy-Quote/

!!编辑!!
function12.inc 中的前几行代码包括在内。 getVenues() 等函数在此声明,包括:

<?php
//############################Venues###############################\\
function getVenues()
{
    include("../Includes/db_bloem_01_logon.inc");             
                $cxn = mysqli_connect($host,$user,$passwd,$dbname);
                $query = "SELECT VenueName FROM venues WHERE ID < 5";
                $results = mysqli_query($cxn, $query) or die ("Could't execute query");

      $allVenues= array();

        $counter = 1;
        while($row = mysqli_fetch_assoc($results))
        {
              extract ($row);
              $allVenues[$counter] = "$VenueName";
              $counter++;
        }     
    return $allVenues;
}

function getVenuePricing()
{
    include("../Includes/db_bloem_01_logon.inc");             
                $cxn = mysqli_connect($host,$user,$passwd,$dbname);
                $query = "SELECT Price FROM venues WHERE ID < 5";
                $results = mysqli_query($cxn, $query) or die ("Could't execute query");

      $allVenuePricing= array();

        $counter = 1;
        while($row = mysqli_fetch_assoc($results))
        {
              extract ($row);
              $allVenuePricing[$counter] = "$Price";
              $counter++;
        }     
    return $allVenuePricing;
}

最佳答案

当您在脚本中使用 php 并且 php 抛出错误时,该错误将打印在脚本标记中,因此它不会显示在您的浏览器中。很有可能你的 javascript 中的 php 有问题。将 php 移到 script 标签之外,以确保它运行无误。

关于php - 当到达 javascript 中的 php 标签时,我的网页停止加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14407314/

相关文章:

php - 返回包含总行数的查询

javascript - 查明嵌套的 ng-repeat 是否显示任何内容

php - 为什么在PHP中发送POST请求时fsockopen有性能问题而不是fopen?

php - 带 session 的 PDO 查询不返回任何内容

php - 处理表连接时如何有效地编写对象类?

php - DES/ECB/PKCS5Padding PHP解密

javascript - 可以在 flexboxes 中使用相对定位吗?

javascript - 使用不符合 noconflict 的外部 JavaScript 文件

javascript - 使用带有 Protractor 的 Firefox 35 导致错误

javascript - 改进 JavaScript 正则表达式以匹配带有或不带有结束标记的标记内的内容,不包括 self