0

嗨,我创建了一个运行良好的 javascript 代码。但是当我在 wordpress 页面上复制该代码时,该代码停止工作。我不知道它为什么停止工作。

我是 wordpress 新手,但我在 javacript 方面有很好的经验。请告诉我为什么代码在 wordpress 页面上不起作用?

这是代码:

    <head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>How Much $$$ Are You Losing</title>
</head>


<script type="text/javascript">// <![CDATA[



    function doCalc() {}
    function doCalc1() {}
    function doCalc2() {}
    function quanBlur(quan) {
        var result = quan / document.form1.newOrdQuan.value * 100;
        document.form1.pctmissed.value = result.toFixed(0) + '%';
        doCalc();
    }
    function pctBlur(pct) {
        var pct1 = +pct.replace(/\D/g, '');
        //document.form1.pctmissed.value=pct1.toFixed(0)+'%';
        var result = document.form1.newOrdQuan.value * pct1 / 100;
        document.form1.quanmissed.value = result.toFixed(0);
        doCalc();
    }


    window.onload = function () {
        document.getElementById("prevOrdQuan").focus();
    }
    function showstep2() {

        document.getElementById('step2').style.visibility = 'visible'
        document.getElementById('newOrdQuan').focus();

    }

    function showstep3() {

        document.getElementById('step3').style.visibility = 'visible';
        document.getElementById('takeOutAmt').focus();
    }



    function showstep4() {
        document.getElementById('step4').style.visibility = 'visible';
        document.getElementById('compsPerWeek').focus();
    }



    function showstep5() {
       // alert('test');
        document.getElementById('step5').style.visibility = 'visible';
        document.getElementsById('avgProfitPerOrder').focus();  // 'avgProfitPerOrder').focus();
    }


    function showstep6() {
        // alert('test');
        document.getElementById('Step6').style.visibility = 'visible';
        //document.getElementsById('avgProfitPerOrder').focus();  // 'avgProfitPerOrder').focus();
    }
    function showstep9() {
        document.getElementById('step9').style.visibility = 'visible';
        document.getElementById('avgProfitPerOrder').focus();
    }

// ]]></script>
<table style="width: 270px; border: 2px navy solid;">
<tbody>
<tr>
<td><form name="form1">
<table style="width: 100%;" align="left">
<tbody>
<tr>
<td>How many TakeOut Orders do You do each week?</td>
<td><input tabindex="1" type="text" name="prevOrdQuan" id="prevOrdQuan" size="6" value="7" onblur="doCalc1(); showstep2();"  /></td>
</tr>
</tbody>
</table>

<table id="step2"  style="width: 100%;  visibility: hidden;"  align="left">
<tbody>
<tr>
<td>How many NEW TakeOut Orders do You expect each week? (15% Expected)</td>
<td><input tabindex="2" type="text" name="newOrdQuan" id="newOrdQuan" size="6" value="7" onblur="doCalc(); showstep3();" /></td>
</tr>
</tbody>
</table>

<table id="step3" style="width: 100%; visibility: hidden;" align="left">
<tbody>
<tr>
<td>How Much Is Your Average Takeout Order?</td>
<td>
<input tabindex="3" type="text" name="takeOutAmt" id="takeOutAmt" size="6" value="20" onblur="doCalc2(); showstep4();" /></td>
</tr>

</tbody>
</table>


<table id="step4" style="width: 100%; visibility: hidden;" align="left">
<tbody>
<tr>
<td>How Many Times a Week do You Comp an Order? (5% expected)</td>
<td><input tabindex="4" type="text" name="compsPerWeek" id="compsPerWeek" size="6" value="1" onblur="doCalc(); showstep9();" /></td>
</tr>
</tbody>
</table>


<table id="step9" style="width: 100%; visibility: hidden; color: green;" align="left">
<tbody>
<tr>
<td>What's Your Average Profit Per Order? (30% Expected)</td>
<td>
<input tabindex="4" type="text" name="avgProfitPerOrder" id="avgProfitPerOrder" size="6" value="6.00" onblur="doCalc();showstep6();" /></td>
</tr>

</tbody>
</table>

<td><input type="text" tabindex="5" name="avgProfitPerOrder" id="avgProfitPerOrder" 


<table id="Step6" style="width: 100%; visibility: hidden; color: green;" align="left">
<tbody>


<tr>
<td class="style1" height="7"></td>
<td class="style1" height="7"></td>
</tr>
<tr>
<td style="color: red;">This is how much money ($$) you are losing each month from TakeOut Orders you Didn't Get...</td>
<td id="monLostRev" style="color: red; font-weight: 900;" align="right">640</td>
</tr>
<tr>
<td style="font-weight: bold;">This is how much PROFIT ($$) you can gain each month with our system</td>
<td id="monrecoveredrev" style="font-weight: 900; text-decoration: underline;" align="right">192.00</td>
</tr>
<tr>
<td>Monthly cost of our system</td>
<td id="montextcost" align="right">-47</td>
</tr>
<tr>
<td>Monthly cost of Credit Card Fees</td>
<td id="monCcCost" align="right">19.20</td>
</tr>
<tr>
<td>Monthly Income Increase ($$) you get using our system</td>
<td id="monroi" style="font-weight: 900; text-decoration: underline;" align="right">125</td>
</tr>
</tbody>
</table>

</form></td>
</tr>
</tbody>
</table>
<a href="#" style="text-decoration: none;">&nbsp;</a>

此代码仅在 wordpress 页面上产生问题。

4

1 回答 1

0

您不能将 Javascript 直接添加到 WordPress 编辑器页面,如果这就是您在 WordPress 页面上复制代码的意思。您必须将其添加到 single.php 页面文件中,您可以通过 Appearance-->Editor 访问该文件

于 2013-10-09T21:32:29.830 回答