2013-10-09 4 views
0

Привет, я создал код javascript, который работает очень хорошо. Но когда у меня есть копия этого кода на страницах Wordpress, тогда этот код перестает работать. Я не знаю, почему он перестает работать.Код 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 страницах.

+0

Вы видели консоль ошибок javascript neha? – codepixlabs

+0

Нет ошибки, этот код работает правильно за пределами wordpress pages.I проверили этот код. Есть ли что-то особенное, что нам нужно добавить на страницах wordpress. – neha

+0

Я думаю, что вы просто прокомментировали тег .. – Twocode

ответ

0

Вы не можете добавить Javascript непосредственно на страницу редактора WordPress, если это то, что вы имеете в виду, копируя код на страницах WordPress. Вы должны добавить его в файл страницы single.php, доступ к которому вы можете получить через Appearance -> Редактор

Смежные вопросы