您好我已经创建了一个非常好的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;"> </a>
此代码仅在wordpress页面上产生问题。
答案 0 :(得分:0)
如果这是你在WordPress页面上复制代码的意思,你不能直接将Javascript添加到WordPress编辑器页面。您必须将它添加到single.php页面文件,您可以通过Appearance - &gt; Editor
访问该文件