Widget:RimCalc: Difference between revisions

Jump to navigation Jump to search
Matt Pijoan (talk | contribs)
No edit summary
Matt Pijoan (talk | contribs)
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 3: Line 3:
$(document).ready(function () {
$(document).ready(function () {
$("#calc").click(function () {
$("#calc").click(function () {
//Modify Below
//Modify Below
var temp = 0;
var temp = 0;
temp = (140 - parseInt($("#input2").val())) * parseInt($("#input1").val());
var weight = 0;
console.log(temp);
var age = 0;
temp = temp / (parseInt($("#input3").val()) * 72)
var serum = 0;
console.log(temp);
if ($("#wtype").val() === "Pounds") {
weight = parseInt($("#input1").val()) * .45;
} else {
weight = parseInt($("#input1").val());
}
age = parseInt($("#input2").val());
serum = parseFloat($("#input3").val());
temp = (140 - age) * weight;
temp = temp / (serum * 72);
if ($("#input4").is(':checked')) {
if ($("#input4").is(':checked')) {
temp = temp * .85;
temp = temp * .85;
Line 15: Line 23:
$("#output").html(temp);
$("#output").html(temp);


                if(temp > 50){$("#output").append("<br />Regular Dose")}
if (temp > 50) {
                else if(temp >= 30 || temp <= 50){$("#output").append("<br />250-500 mg q12h")}
$("#output").append("<br />Regular Dose")
                else if(temp >= 5 || temp <= 29){$("#output").append("<br />250-500 mg q18h")}
} else if (temp >= 30 || temp <= 50) {
//Don't touch!
$("#output").append("<br />250-500 mg q12h")
} else if (temp <= 29) {
$("#output").append("<br />250-500 mg q18h")
}
//Don't touch below!
});
});
});
});


</script>
</script>
Weight: <input type="text" id="input1" /><br />
<table>
Age: <input type="text" id="input2" /><br />
<tr><td>Weight (kg):</td><td> <input type="text" id="input1" /></td><td><select id="wtype"><option value="Kilograms">Kilograms</option><option value="Pounds">Pounds</option></select></td></tr>
Serum: <input type="text" id="input3" /><br />
<tr><td>Age: </td><td><input type="text" id="input2" /></td><td></td></tr>
Female? <input type="checkbox" id="input4" /><br />
<tr><td>Serum: </td><td><input type="text" id="input3" /></td><td></td></tr>
<input type="button" value="Calc" id="calc" />
<tr><td>Female? </td><td><input type="checkbox" id="input4" /></td><td></td></tr>
<tr><td colspan="2"><input type="button" value="Calc" id="calc" /></td><td></td></tr>
</table>
<div id="output"></div>
<div id="output"></div>
</includeonly>
</includeonly>

Latest revision as of 16:26, 13 March 2014