Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding Numeric Values through Javascript & PHP
    primarykey
    data
    text
    <p>Basically I am trying to multiply values together.</p> <p>I have a ul below that is echo'ing out a numeric value,:</p> <pre><code>&lt;ul class="TCE"&gt; &lt;li&gt;&lt;span&gt;Average drink cost&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;?php echo the_field('average_drink_price'); ?&gt;&lt;/li&gt; &lt;li&gt;&lt;span&gt;Average drinks spenditure per night&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;?php echo the_field('average_drinks_spenditure_per_night'); ?&gt;&lt;/li&gt; &lt;li&gt;&lt;span&gt;Average drinks spenditure for the year&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;!-- JAVA BIT --&gt;&lt;/li&gt; &lt;li&gt;&lt;span&gt;Average drinks spenditure for 3 years&lt;/span&gt;&amp;nbsp;&amp;nbsp; &lt;!-- JAVA BIT --&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I want the third li to get the value of the second li and then multiply that value by exactly 28.</p> <p>I then want the fourth li to get the value of the third li and multiply that by 3.</p> <p>So it goes a little like this: </p> <p>li-2 x 28 = li-3 li-3 x 3 = li-4</p> <p>If that makes sense? The value's for li1 and li2 will be generated via that PHP field, any help on this as I have no idea where to start?</p> <p>Updated PHP testing:</p> <pre><code>&lt;?php var_dump(the_field('average_drinks_spenditure_per_night')); $li2 = the_field('average_drinks_spenditure_per_night'); $li3 = ($li2 * 28) * 2.1; $li4 = $li3 * 3; ?&gt; &lt;ul class="TCE"&gt; &lt;li&gt;&lt;span&gt;Average drink cost&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;?php echo the_field('average_drink_price'); ?&gt;&lt;/li&gt; &lt;li&gt;&lt;span&gt;Average drinks spenditure per night&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;?php echo $li2; ?&gt;&lt;/li&gt; &lt;li&gt;&lt;span&gt;Average drinks spenditure for the year&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;?php echo $li3;?&gt;&lt;!-- JAVA BIT --&gt;&lt;/li&gt; &lt;li&gt;&lt;span&gt;Average drinks spenditure for 3 years&lt;/span&gt;&amp;nbsp;&amp;nbsp; &lt;?php echo $li4;?&gt;&lt;!-- JAVA BIT --&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre>
    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