Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

1. ## Mixing ratio calkulator..

I have made a simple mixing ratio calculator for Oil's and other substances..

Now I want to ad another step of mixing. eg if you are mixing detailing schampoo at a 1:20 ratio, then you put it in a foam lance (a power washer ad-on that mixes shampoo to your water while washing your car)

As you can see, today you can chose your desired volume of mixed fluid and add the desired mixing ratio to get how many dl of f.e. concentrated schampoo you need to ad to your mix.

after the calculation is done I want to be able to set my foam lance mixing ratio, lets say 1:40 and the script would calculate what your final output mixing ratio is, based on the mixing ratio in the first step.

I would be really glad if anyone could help med whit this..

Here is the calculator. Sorry that it is in swedish..

Best regards
Fox

• I don't understand this, at all:
Code:
```        var gastm = document.gasoil.gasm.value; //get liters
var gasom = (gastm * 10); //convert petrol to ml```
That doesn't convert liters to ml !!

It converts it to deciliters!

• Yes. In the original script it was converted to ml (1000). But I wanted it to be displayed in dl, so I changed the conversion, but forgot to change this line of text.. Sorry for that.

• Do you understand what I mean in my first post?

If i dilute the car schampoo by 1:50 in the first step. Then my foam gun on the power washer dilutes the previous diluted substance by 1:20, 1:40, 1:80 or whatever (this ratio is user specific) What final dilution do I get? Or even better, If I could determine the final dilution, say 1:400 and given the foam lance dilution f.e 1:30 and the amount of ready to use substance (Liters). The script could tell me what amount of concentrated schampoo I should use in the first mix...

Best regards

• If you want to start with a specified final dilution, you will need to rework your script. Something like:-

Code:
```<script type = "text/javascript">

var fd = 400;  // final dilution
var ld = 30;  // lance dilution
var qty = 1000;  // litres of water
var result = qty/ld/fd;

</script>```

We are sorry that as a result of a typographical error we referred to the well-known English actor Denis Prick.
This should of course have read Pe*is Price.

• Originally Posted by Philip M
If you want to start with a specified final dilution, you will need to rework your script. Something like:-

Code:
```<script type = "text/javascript">

var fd = 400;  // final dilution
var ld = 30;  // lance dilution
var qty = 1000;  // litres of water
var result = qty/ld/fd;

</script>```

We are sorry that as a result of a typographical error we referred to the well-known English actor Denis Prick.
This should of course have read Pe*is Price.
Thank you?. I don't know what you mean by the blue text, should I be offended? Or have I done something wrong?

I am no programmer or coader, that's for sure. But I am trying to use the very little knowledge that I have to accomplish this little calculator. I'ts for a small detailing forum so it is all "pro bono" and non commercial.

I found a script that does what I want with the serial dilution in the foam lance. However, the code is so messy and not written by the same "artist" as the one posten above so I have a very hard time trying to figure out what's what and what's not.

This is the two scripts that more or less accomplish what I want

Easy mixing ratio:
Code:
```    function clear_field(field) {
if (field.value == field.defaultValue) {
field.value = ''
}
}

function calcOil() {
var gastm = document.gasoil.gasm.value; //get liters
var gomrtm = document.gasoil.gomrm.value; //get mixture ratio
var gasom = (gastm * 10); //convert petrol to dl
var oilom = ((gasom) / gomrtm); //divide by ratio
document.gasoil.oilqtym.value = (oilom); //required oil
document.gasoil.gomr.value = (document.gasoil.gomrm.value); //mixture ratio
document.gasoil.oilqty.value = (oilom * 0.033814022701843); //required oil converted to ounces
}```
(I will remove the ounces conversion since I don't need it)

Serial dilution with the foam lance:
Code:
```function pwCalc()
{
var C = document.getElementById("fin_mr_num").value / (document.getElementById("fin_mr_den").value * 1.0 + document.getElementById("fin_mr_num").value * 1.0) * (document.getElementById("pw_mr_den").value * 1.0 + document.getElementById("pw_mr_num").value * 1.0) / document.getElementById("pw_mr_num").value;
document.getElementById("premixConcentration").value = (C * 100).toFixed(2);
document.getElementById("detergent_vol").value = (C * document.getElementById("premix_vol").value).toFixed(3);
document.getElementById("detergent_vol_oz").value = (C * document.getElementById("premix_vol").value * 1000).toFixed(1);
document.getElementById("water_vol").value = ((1-C) * document.getElementById("premix_vol").value).toFixed(3);
document.getElementById("water_vol_oz").value = ((1-C) * document.getElementById("premix_vol").value * 1000).toFixed(1);
}```
I changed the "detergent_vol_oz" and "water_vol_oz" premix value from 128 to 1000 to go from fl. oz to milliliters. Does this apply the right way?

Is there a way to combine the two to have a more optimized script?

If so, or if not. The tricky part for me is to wrap it all in html tabs or CSS to present it well to the users. I have tried to use wysiwyg editors but that just seems to mess it all up even more..

Code:
```<meta charset="UTF-8" />
<title></title>
<center>&nbsp;</center>

<p align="center">&nbsp;</p>

<div align="center">
<center>
<table border="1" bordercolor="#C0C0C0" cellpadding="10" cellspacing="1" cols="1" style="background-color: #FFFFFF; width: 550px;">
<tbody>
<tr>
<td style="width: 500px;">
<p align="center" style="background-color: #FFFFFF;"><span style="color:#000000;"><b><img height="62" src="bbv_logo_color.png" width="456" /></b></span></p>

<hr />
<p><span style="color:#000000;">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation</span></p>

<p>&nbsp;</p>

<form name="gasoil">
<center>
<table border="1" bordercolordark="#999999" cellpadding="10" cellspacing="1" cols="1" width="350">
<tbody>
<tr>
<td>
<p align="right"><span style="color:#000000;">Ammount of final dilution (in Liters):</span></p>
</td>
<td><span style="color:#000000;"><input name="gasm" onfocus="clear_field(this)" size="6" type="text" value="1" /></span></td>
</tr>
<tr>
<td>
<p align="right"><span style="color:#000000;">Desired dilution ratio:</span></p>
</td>
<td><span style="color:#000000;"><input name="gomrm" onfocus="clear_field(this)" size="6" type="text" value="50" />:1</span></td>
</tr>
<tr>
<td colspan="2">
<center><span style="color:#000000;"><input onclick="calcOil()" type="button" value="Beräkna" />&nbsp;&nbsp;&nbsp; <input type="reset" value="Nollställ" /></span></center>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
</tbody>
</table>
</center>
</form>

<hr />
<p>&nbsp;</p>
</td>
</tr>
</tbody>
</table>
</center>
</div>

<p><span style="color:#000000;">This calculator computes the amount of detergent needed in the pre-mix jug, using the given mixing ratios.</span></p>

<table>
<tbody>
<tr>
<td>
<table class="calc">
<tbody>
<tr style="font-size:small">
<th>&nbsp;</th>
<th><span style="color:#000000;">Detergent</span></th>
<th><span style="color:#000000;">Water</span></th>
</tr>
<tr>
<td><span style="color:#000000;">Final Mixing Ratio:</span></td>
<td><span style="color:#000000;"><input id="fin_mr_num" size="3" value="1" />:</span></td>
<td><span style="color:#000000;"><input id="fin_mr_den" size="3" value="20" /></span></td>
</tr>
<tr>
<td><span style="color:#000000;">Pressure Washer Mixing Ratio:</span></td>
<td><span style="color:#000000;"><input id="pw_mr_num" size="3" value="1" />:</span></td>
<td><span style="color:#000000;"><input id="pw_mr_den" size="3" value="7" /></span></td>
</tr>
</tbody>
</table>
</td>
<td><span style="color:#000000;"><span class="small" style="position:relative; top:2em">Tip: Set to 1:0 for a general mixing calculation.</span></span></td>
</tr>
</tbody>
</table>

<p><span style="color:#000000;">Desired Volume of Pre-mix:&nbsp;<input id="premix_vol" size="3" value="1" />&nbsp;Liters<br />
<br />
<input name="pwButton" onclick="pwCalc()" type="button" value="Calculate..." /></span></p>

<table class="calc">
<tbody>
<tr>
<td><span style="color:#000000;">Pre-mix Concentration:</span></td>
<td><span style="color:#000000;"><input id="premixConcentration" size="5" />%</span></td>
<td>&nbsp;</td>
</tr>
<tr>
<td><span style="color:#000000;">Detergent:</span></td>
<td><span style="color:#000000;"><input id="detergent_vol" size="5" />L=</span></td>
<td><span style="color:#000000;"><input id="detergent_vol_oz" size="5" /> ml</span></td>
</tr>
<tr>
<td><span style="color:#000000;">Water:</span></td>
<td><span style="color:#000000;"><input id="water_vol" size="5" />L=</span></td>
<td><span style="color:#000000;"><input id="water_vol_oz" size="5" /> ml</span></td>
</tr>
</tbody>
</table>

<p><span style="color:#000000;">The water volume needs typically not be measured since we can just top up the jug with water.</span></p>```
You can find the calculator live Here!

I appreciate all the help I can get and will try to learn as much as a can.

Best regards..

• By "Is there a way to combine the two to have a more optimized script?" I mean if there is a way to combine the to java scripts to have it more optimized, not combining the premix values

Why can't you edit posts, or have I missed ?

• Originally Posted by Fox32
Thank you?. I don't know what you mean by the blue text, should I be offended? Or have I done something wrong?
No. I often add some sort of quotation to my posts (in blue) which are intended to amuse or perhaps instruct. It is a joke. I am told that Swedes have no sense of humour. Like Björn Borg.

You cannot edit your posts until you have made 10 posts. That is an anti-spam measure to block people who post innocuous material which passes the moderators and then edit it to make it into spam.

I have tried to use wysiwyg editors but that just seems to mess it all up even more.
Yes, that is often the case.

• Originally Posted by Philip M
I am told that Swedes have no sense of humour. Like Björn Borg.
Haha, Björn Borg has no sense of humor because he is stupid (throwing bricks in a glass house here)... =)

I notised your little amusements in other threads as well when I was scouting the forum yesterday. So no offense taken even if that was not your intention.. =)

You seem to be really good at this programming game of what I have read in other threads, I would be really glad if you would like to help me out with the poor scripting in my previous post..

// Fox

• Anyone?

• If I pay for someone to help me?... I am desperate..

•

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•