Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <table>
- <tr>
- <td>What are you selling:(M,C,D)<input type="text" maxlength="1"/></td>
- </tr><tr>
- <td>How much of that:<input type="number" id="howMuch" /></td>
- </tr><tr>
- <td>ratio of the two things you whish to get:<input id="A" type="number"><input id="B" type="number"></td>
- </tr><tr>
- <td>ratios:(something:something:what your selling)<input id="M" type="number" /><input id="C" type="number" /><input id="D" type="number" /></td>
- </tr><tr><td>
- <input type="button" onclick="calculate()" value="Calculate" />
- </td></tr><tr>
- <td>Amounts you will get: <x id="amount1"></x>:<x id="amount2"></x></td></tr>
- </table>
- <script>
- function calculate(){
- //get amount
- var H = document.getElementById('howMuch').value;
- //get rates
- var C = document.getElementById('M').value;
- var D = document.getElementById('C').value;
- var E = document.getElementById('D').value;
- //get ration of buying
- var A = document.getElementById('A').value;
- var B = document.getElementById('B').value;
- var G = H*C*D;
- var AB = A/B;
- var DC = Number(D)+Number(C);
- G = 2*G/(E*(AB+1)*(DC));
- var F = AB*G;
- document.getElementById('amount1').innerHTML = F;
- document.getElementById('amount2').innerHTML = G;
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment