Note that there are some explanatory texts on larger screens.

plurals
  1. POI have a variable in javascript that is not being set to the proper value
    primarykey
    data
    text
    <pre><code>&lt;html&gt; &lt;head&gt; &lt;script language="JavaScript"&gt; var pizza = 0; var tops = 0; var count = 0; var total = 0; var subtotal = 0; var tax = 0; var cheesecost = 0; function getcheese(yesno) { switch (yesno) { case 1: if (type == 1) { cheesecost = 1; } if (type == 2) { cheesecost = 1; } if (type == 3) { cheesecost = 1.25; } if (type == 4) { cheesecost = 1.4; } break; case 2: cheesecost = 0; break; } } function calc() { count = document.getElementById("toppingbox").value; subtotal = pizza + (tops * count) + cheesecost; tax = parseFloat(subtotal) * .06; total = parseFloat(tax) + parseFloat(subtotal); alert(cheesecost); document.getElementById("taxbox").value = tax.toFixed(2); document.getElementById("subtotalbox").value = subtotal.toFixed(2); document.getElementById("totalbox").value = total.toFixed(2); } function gettype(type) { if (type == 1) { pizza = 4; tops = .5; } if (type == 2) { pizza = 7.25; tops = .6; } if (type == 3) { pizza = 9.25; tops = .75; } if (type == 4) { pizza = 12.9; tops = .9; } } &lt;/script&gt; &lt;/head&gt; &lt;body style="padding-top: 64px; background-color: #e6e6e6"&gt; &lt;center&gt; &lt;h1&gt;Online Pizza Order Form&lt;/h1&gt; &lt;/center&gt; &lt;hr noshade="noshade" style="text-align: center;width: 35%; height: 6px; color: gray; border-style: ridge; border-color: grey; border-width: 2px"&gt; &lt;form&gt; &lt;div style="text-align: center;"&gt; &lt;div style="text-align: center; padding-left: 24px; padding-top: 16px; padding-right: 24px; padding-bottom: 16px; border-width: 2px; border-style: ridge; background-color:#d8d8d8; width:28%; margin-bottom: 4px;"&gt; &lt;hr noshade="noshade" style="text-align: center; margin-top:-12px; height: 2px; color: gray; border-style: ridge; border-width: 2px"&gt; &lt;b&gt;Select the pizza type&lt;/b&gt; &lt;br&gt; &lt;div style="padding-left: 64px; text-align: left; padding-top: 12px; padding-bottom: 12px;"&gt; &lt;table border="0"&gt; &lt;tr&gt; &lt;td&gt;1. 6' - $4.00&lt;/td&gt; &lt;td&gt; &lt;input type=radio name=pizzatype value="1" onclick="gettype(this.value)"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;2. 10' - $7.25&lt;/td&gt; &lt;td&gt; &lt;input type=radio name=pizzatype value="2" onclick="gettype(this.value)"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;3. 14' - $9.25&lt;/td&gt; &lt;td&gt; &lt;input type=radio name=pizzatype value="3" onclick="gettype(this.value)"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;4. 16' - $12.90&lt;/td&gt; &lt;td&gt; &lt;input type=radio name=pizzatype value="4" onclick="gettype(this.value)"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;hr noshade="noshade" style="text-align: center; height: 2px; color: gray; border-style: ridge; border-width: 2px"&gt; &lt;!-- START TEXT INPUTS --&gt; &lt;table border="0"&gt; &lt;tr&gt; &lt;td style="font-weight: bold;"&gt;How many toppings do you want?&lt;/b&gt;&amp;nbsp;&lt;/td&gt; &lt;td style="font-weight: bold;"&gt; &lt;input id="toppingbox" type="text" style="width:50px;" /&gt; &lt;br&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style="font-weight: bold;"&gt;Do you want extra cheese?&lt;/td&gt; &lt;td style="font-weight: bold;"&gt;Yes &lt;input type=radio name=checkcheese value="1" onclick="getcheese(this.value)"&gt; &lt;br&gt;No &lt;input type=radio name=checkcheese value="2" onclick="getcheese(this.value)"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;!-- END TEXT INPUTS --&gt; &lt;!-- CALCULATE BUTTON --&gt; &lt;hr noshade="noshade" style="text-align: center; height: 2px; color: gray; border-style: ridge; border-width: 2px"&gt; &lt;div style="text-align: center;"&gt; &lt;button onclick="calc()"&gt;Calculate&lt;/button&gt; &lt;/div&gt; &lt;hr noshade="noshade" style="text-align: center; height: 2px; color: gray; border-style: ridge; border-width: 2px"&gt; &lt;!-- END CALCULATE BUTTON --&gt; &lt;!-- START TOTALS --&gt; &lt;table border="0"&gt; &lt;tr&gt; &lt;td style="font-weight: bold;"&gt;Subtotal:&lt;/td&gt; &lt;td&gt;$ &lt;input id="subtotalbox" readonly="readonly" type="text" style="width:64px; background-color: #bdbdbd; font-weight:bold;" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style="font-weight:bold;"&gt;Tax Due:&lt;/td&gt; &lt;td&gt;$ &lt;input id="taxbox" readonly="readonly" type="text" style="width:64px; background-color: #bdbdbd;" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style="font-weight:bold;"&gt;Total Due:&lt;/td&gt; &lt;td&gt;$ &lt;input id="totalbox" readonly="readonly" type="text" style="width:64px; background-color: #bdbdbd;" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;!-- END TOTALS --&gt; &lt;hr noshade="noshade" style="text-align: center; margin-bottom:-8px; margin-top: 12px; height: 2px; color: gray; border-style: ridge; border-width: 2px"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;hr noshade="noshade" style="text-align: center; width: 35%; height: 6px; color: gray; border-style: ridge; border-color: grey; border-width: 2px"&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>the cheesecost variable is supposed to change depending on the pizza size. when the yes/no radio button is checked, it is supposed to either set the cheesecost to 0, or set it to the cheese price related to that specific pizza size. ive been stuck on this for 3 days now, and ive tried about 12 different ways of doing this. none of them seem to work. for some reason the alert that displays the cheese cost is always zero, why is this?</p>
    singulars
    1. This table or related slice is empty.
    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