Note that there are some explanatory texts on larger screens.

plurals
  1. POjavascript function says that is undefined
    primarykey
    data
    text
    <p>all I've written a function in order to calculate many things,</p> <p>so I've put the value of my vars in input of type hidden, so we have this code:</p> <pre><code> &lt;input type="hidden" id="p1" value="5000.00"&gt; &lt;input type="hidden" id="p2" value="5000.01"&gt; &lt;input type="hidden" id="p3" value="8000.00"&gt; &lt;input type="hidden" id="p4" value="8000.01"&gt; &lt;input type="hidden" id="t1" value="15.0"&gt; &lt;input type="hidden" id="t2" value="12.0"&gt; &lt;input type="hidden" id="t3" value="6.0"&gt; &lt;input type="hidden" id="versement" value="12554.35"&gt; &lt;input type="hidden" id="type" value="d"&gt; </code></pre> <p>Moreover, I've have the following code, first an input in order to write the amount to be calculated:</p> <p>and the function on the top:</p> <p>so we have:</p> <pre><code> &lt;script language="text/javascript"&gt; function hono(p1,p2,p3,p4,t1,t2,t3,type,versement,montantacompte) { var p1 = document.getElementById("p1").value; var p2 = document.getElementById("p2").value; var p3 = document.getElementById("p3").value; var p4 = document.getElementById("p4").value; var t1 = document.getElementById("t1").value; var t2 = document.getElementById("t2").value; var t3 = document.getElementById("t3").value; var type = document.getElementById("type").value; var versement = document.getElementById("versement").value; var montantacompte = document.getElementById("montantacompte").value; if (type== "d") { if(versement== 0 &amp;&amp; montantacompte &lt;= p1) { reste1= montantacompte; pc= t1/100; taux1= pc+1; h1=((reste1*taux1)+reste1); honoraires=h1; document.getElementById('taux-1').value=taux1; document.getElementById('palier1').value=h1; document.getElementById('sommehonoraires').value=honoraires; } else if(versement &lt; p1 &amp;&amp; (versement + acompte) &lt;= p1) { reste1= montantacompte; pc= t1/100; taux1= pc+1; h1= (reste1*taux1)-reste1; honoraires= h1; document.getElementById('taux-1').value=taux1; document.getElementById('palier1').value=h1; document.getElementById('sommehonoraires').value=honoraires; } else if(versement &lt;= p1 &amp;&amp; (versement+montantacompte)&gt;= p2 &amp;&amp; (versement+montantacompte)&lt;=p3) { reste1=p1-versement; pc=t1/100; taux1=pc+1; h1=(reste1*taux1)-reste1; reste2=montantacompte-reste1; pc2=t2/100; taux2=pc2+1; h2=(reste2*taux2)-reste2; honoraires=h1+h2; document.getElementById('taux-1').value=taux1; document.getElementById('palier1').value=h1; document.getElementById('taux-2').value=taux2; document.getElementById('palier-2').value=h2; document.getElementById('sommehonoraires').value=honoraires; } else if (versement==0 &amp;&amp; montantacompte&gt;=p2 &amp;&amp; montantacompte &lt;=p3) { reste2=montantacompte-p1; reste1=p1; pc=(t1/100); taux1=pc+1; h1=((reste1*taux1)-reste1); pc2=(t2/100); taux2=pc2+1; h2=((reste2*taux2)-reste2); honoraires=(h1+h2); document.getElementById('taux-1').value=taux1; document.getElementById('palier1').value=h1; document.getElementById('taux-2').value=taux2; document.getElementById('palier2').value=h2; document.getElementById('sommehonoraires').value=honoraires; } else if(versement&lt;=p3 &amp;&amp; versement&gt;=p2 &amp;&amp; (versement+montantacompte)&gt;=p2 &amp;&amp; (versement+montantacompte)&lt;=$3) { reste1=montantacompte; pc=($2/100); taux1=pc+1; h1=((reste1*taux1)-reste1); honoraires=h1; document.getElementById('taux-1').value=taux1; document.getElementById('palier1').value=h1; document.getElementById('sommehonoraires').value=honoraires; } else if(versement&gt;=p2 &amp;&amp; versement&lt;=p3 &amp;&amp; (versement+montantacompte)&gt;=p4) { reste1=p4-versement; pc=(t2/100); taux2=pc+1; h2=((reste1*taux2)-reste1); reste2=montantacompte-reste1; pc2=(t3/100); taux3=pc2+1; h3=((reste2*taux3)-reste2); honoraires=(h2+h3); document.getElementById('taux-3').value=taux3; document.getElementById('palier3').value=h3; document.getElementById('taux-2').value=taux2; document.getElementById('palier2').value=h2; document.getElementById('sommehonoraires').value=honoraires; } else if(versement==0 &amp;&amp; montantacompte&gt;=p4) { reste1=p1; reste2=p3-p2; pc=(t1/100); taux1=pc+1; h1=((reste1*taux1)-reste1); pc2=(t2/100); taux2=pc2+1; h2=((reste2*taux2)-reste2); reste3=(montantacompte-reste1-reste2); pc3=(t3/100); taux3=pc3+1; h3=((reste3*$taux3)-reste3); honoraires=(h1+h2+h3); document.getElementById('taux-1').value=taux1; document.getElementById('palier1').value=h1; document.getElementById('taux-3').value=taux3; document.getElementById('palier3').value=h3; document.getElementById('taux-2').value=taux2; document.getElementById('palier2').value=h2; document.getElementById('sommehonoraires').value=honoraires; } else if(versement&gt;=p4) { reste3=montantacompte; pc3=($3/100); taux3=pc3+1; h3=((reste3*taux3)-reste3); honoraires=(h3); document.getElementById('taux-3').value=taux3; document.getElementById('palier3').value=h3; document.getElementById('sommehonoraires').value=honoraires; } } if (type=="l") { pc1=(t1/100); taux1=pc1+1; honoraires=montantacompte*taux1; document.getElementById('taux-1').value=taux1; document.getElementById('palier1').value=h1; document.getElementById('sommehonoraires').value=honoraires; } } &lt;/script&gt;&lt;input type="text" name="montantacompte" id="montantacompte" onKeyUp="hono(p1,p2,p3,p4,t1,t2,t3,type,versement,montantacompte)" /&gt; </code></pre> <p>And in the console it says to me that the function is not defined, or it is, because i've written it... All is in the body.</p> <p>We have this in the console:</p> <blockquote> <p>Uncaught ReferenceError: hono is not defined test.php:166 onkeyup</p> </blockquote> <p>and the line 166 is where there is the input type text after the function.</p> <p>sorry for my bad English,</p> <p>If you need more precisions, just ask me,</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload