var s_method = "1";
var lye_type = "2";
var lye = "0";
$("tr[id=NaOH]").hide(); // hide initial
$("input[name='s_method']:radio").change(function(){
if($(this).val() == '1'){ // If Water:Lye Ratio Method Selection
$("input[id=lc]").attr("disabled", true); // Disable Lye Concentrate Editing
$("input[id=wpo]").attr("disabled", true); // Disable Water as % of Oil Editing
$("input[id=wr]").attr("disabled", false); // Enable Water Lye Ratio Editing
s_method = "1";
}
else if($(this).val() == '2'){ // If Lye Concentrate Method Selection
$("input[id=lc]").attr("disabled", false); // Enable Lye Concentrate Editing
$("input[id=wpo]").attr("disabled", true); // Disable Water as % of Oil Editing
$("input[id=wr]").attr("disabled", true); // Disable Water Lye Ratio Editing
if(!$.isNumeric($('#lc').val())) { document.getElementById('lc').value = 33.33; } // Default value
s_method = "2";
}
else if($(this).val() == '3'){ // If Water as a Percentage of Oil Method Selection
$("input[id=lc]").attr("disabled", true); // Disable Lye Concentrate Editing
$("input[id=wpo]").attr("disabled", false); // Enable Water as % of Oil Editing
$("input[id=wr]").attr("disabled", true); // Disable Water Lye Ratio Editing
if(!$.isNumeric($('#wpo').val())) { document.getElementById('wpo').value = 27.09; } // Default Value
s_method = "3";
}
});
$("input[name='lye_type']:radio").change(function(){
if($(this).val() == '2'){
$("tr[id=NaOH]").hide();
$("tr[id=KOH]").show();
lye_type="2";
} else {
$("tr[id=KOH]").hide();
$("tr[id=NaOH]").show();
lye_type="1";
}
});
$('input').on('keyup change', function() { // run anytime the value changes
// get value of field
// convert it to a float
var wr = Number($('#wr').val()); // Water ratio
var lr = Number($('#lr').val()); ...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.