I have a script that I am working on for an intranet tool and in this
script I have a form, which when submitted the onSubmit command calls
calculate(). In this calculate function, I have it do some calculations
and write out a new document using document.write( ). One of the lines
it writes is (the whole script is at the bottom of this email).
pageData = PageData+"<b>Pa tient Data</b><br>Wt: "+weight+"
"+weightUni ts+"    Ht: "+height+"i n    Gender:
"+gender+"<br>< a href=\"index.ht ml\">Back To Form</a>";
When I click on this link to "reload" the page and have the original
form show up again, it works but in the javascript console i get errors
saying:
-The link to
file:///C:/Server/Apache%20Group/Apache2/htdocs/heparin/index.html was
blocked by the security manager.
Remote content may not link to local content.
-Error: uncaught exception: Load of
file:///C:/Server/Apache%20Group/Apache2/htdocs/heparin/index.html denied.
The basic goal of the link is to destory the page that was written by
the funtion and to just display the form again.
I am not a computer programmer by training, so maybe I am going about
this wrong. Please let me know how to get rid of these error messages.
If you have any other tips on things that I am doing strange in this
script, let me know. I am fairly familier with java and PHP, but this
is my first real dealings with javascript.
Thanks,
Andrew V. Romero
--The Whole Script--
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Andrew V. Romero" content="romero ">
<meta name="GENERATOR " content="Mozill a/4.7 [en] (Win98; U) [Netscape]">
<title>UMC Out of Range Heparin Protocol</title>
</head><body background="coc tail3.gif" link="#0000DD" vlink="#0000DD"
alink="#0000DD" >
<center><font size=+3>UMC Demo Heparin Protocol</font><font
size=+3></font></center><br>
<script language="JavaS cript">
function calculate()
{
if (document.form. weight.value != "" && document.form.h eight.value !=
"" && document.form.a ge.value != "")
{
//0 is kg
if (document.form. wtUnits[0].checked)
{
weight = document.form.w eight.value;
weightUnits = "kg"
}
else if (document.form. wtUnits[1].checked)
{
weight = document.form.w eight.value / 2.2
weightUnits = "lbs"
}
height = document.form.h eight.value;
age = document.form.a ge.value;
var rate;
var gender;
var bolus;
//for males
if (document.form. gender[0].checked)
{
gender = "male"
//AMI
if (document.form. diagnosis[0].checked)
{
rate = -336.4 + (6.52*weight) + (22*height) - (7.52*age)
}
//USA
else if (document.form. diagnosis[1].checked)
{
rate = -336.4 + (6.52*weight) + (22*height) - (7.52*age) - 142
}
//AFib
else if (document.form. diagnosis[2].checked)
{
rate = -336.4 + (6.52*weight) + (22*height) - 7.52 - 142
}
}
//for females
else if (document.form. gender[1])
{
gender = "female"
//AMI
if (document.form. diagnosis[0].checked)
{
rate = -336.4 + (6.52*weight) + (22*height) + (2.71*age) - 749.2
}
//USA
else if (document.form. diagnosis[1].checked)
{
rate = -336.4 + (6.52*weight) + (22*height) + (2.71*age) - 672.3
}
//AFib
else if (document.form. diagnosis[2].checked)
{
rate = -336.4 + (6.52*weight) + (22*height) + (2.71*age) - 672.3
}
}
//AMI USA or AFib bolus
if (document.form. diagnosis[0] || document.form.d iagnosis[1] ||
document.form.d iagnosis[2])
{
//want bolus
if (document.form. bolus[0].checked)
{
bolus = 50 * weight;
}
//doesn't want bolus
else if (document.form. bolus[1].checked)
bolus = "No Bolus Requested";
}
//DVT and PE bolus and infusion
if (document.form. diagnosis[3].checked)
{
alert("test");
rate = 18 * weight;
//if want bolus
if (document.form. bolus[0].checked)
{
bolus = 80 * weight;
}
//doesn't want bolus
else if (document.form. bolus[1].checked)
bolus = "No Bolus Requested";
}
var pageData;
pageData = "<html><head><m eta http-equiv=\"Content-Type\"
content=\"text/html; charset=iso-8859-1\"><meta name=\"Andrew V.
Romero\" content=\"romer o\"><title>UM C Out of Range Heparin
Protocol</title></head><body background=\"co ctail3.gif\"
link=\"#0000DD\ " vlink=\"#0000DD \" alink=\"#0000DD \"><center><fon t
size=+3>UMC Demo Heparin Protocol</font><font size=+3></font></center>";
pageData = PageData+"<b>Pa tient Data</b><br>Wt: "+weight+"
"+weightUni ts+"    Ht: "+height+"i n    Gender:
"+gender+"<br>< a href=\"index.ht ml\">Back To Form</a>";
alert ("Infusion Rate: "+rate+" units/hr "+gender);
document.write( pageData);
document.close( );
}
else
alert ("Please Fill In All Fields");
}
</script>
<form name="form" method="get" action="" onSubmit=calcul ate();>
<table border =1>
<tr><td colspan=3><b>Pa tient Data</b></td></tr>
<tr><td><b>Weig ht (kg)</b></td><td><input name="weight" size=5><input
type="radio" name="wtUnits" value="kg" checked>Kg   <inpu t
type="radio" name="wtUnits" value="lb">lbs</td></tr>
<tr><td><b>Heig ht (in)</b></td><td><input name="height" size=3></td></tr>
<tr><td><b>Ag e</b></td><td><input name="age" size=3></td></tr>
<tr><td><b>Gend er</b></td><td><input type="radio" name="gender"
value="male" checked>Male    <input type="radio" name="gender"
value="female"> Female</td></tr>
<tr><td><b>Diag nosis</b> </td><td><input type="radio" name="diagnosis "
value="AMI" checked>AMI    <input type="radio" name="diagnosis "
value="USA">USA    <input type="radio" name="diagnosis "
value="AFib">Af ib   <inpu t type="radio" name="diagnosis "
value="DVTorPE" >DVT or PE</td></tr>
<tr><td><b>Bolu s</b></td><td><input type="radio" name="bolus"
value="yes" checked>Yes    <input type="radio" name="bolus"
value="no">No</td></tr>
</table>
<div align=right><br ><input TYPE = "submit" Value = " Calculate
"></div></form>
<hr><br>
</form>
</body>
</html>
script I have a form, which when submitted the onSubmit command calls
calculate(). In this calculate function, I have it do some calculations
and write out a new document using document.write( ). One of the lines
it writes is (the whole script is at the bottom of this email).
pageData = PageData+"<b>Pa tient Data</b><br>Wt: "+weight+"
"+weightUni ts+"    Ht: "+height+"i n    Gender:
"+gender+"<br>< a href=\"index.ht ml\">Back To Form</a>";
When I click on this link to "reload" the page and have the original
form show up again, it works but in the javascript console i get errors
saying:
-The link to
file:///C:/Server/Apache%20Group/Apache2/htdocs/heparin/index.html was
blocked by the security manager.
Remote content may not link to local content.
-Error: uncaught exception: Load of
file:///C:/Server/Apache%20Group/Apache2/htdocs/heparin/index.html denied.
The basic goal of the link is to destory the page that was written by
the funtion and to just display the form again.
I am not a computer programmer by training, so maybe I am going about
this wrong. Please let me know how to get rid of these error messages.
If you have any other tips on things that I am doing strange in this
script, let me know. I am fairly familier with java and PHP, but this
is my first real dealings with javascript.
Thanks,
Andrew V. Romero
--The Whole Script--
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Andrew V. Romero" content="romero ">
<meta name="GENERATOR " content="Mozill a/4.7 [en] (Win98; U) [Netscape]">
<title>UMC Out of Range Heparin Protocol</title>
</head><body background="coc tail3.gif" link="#0000DD" vlink="#0000DD"
alink="#0000DD" >
<center><font size=+3>UMC Demo Heparin Protocol</font><font
size=+3></font></center><br>
<script language="JavaS cript">
function calculate()
{
if (document.form. weight.value != "" && document.form.h eight.value !=
"" && document.form.a ge.value != "")
{
//0 is kg
if (document.form. wtUnits[0].checked)
{
weight = document.form.w eight.value;
weightUnits = "kg"
}
else if (document.form. wtUnits[1].checked)
{
weight = document.form.w eight.value / 2.2
weightUnits = "lbs"
}
height = document.form.h eight.value;
age = document.form.a ge.value;
var rate;
var gender;
var bolus;
//for males
if (document.form. gender[0].checked)
{
gender = "male"
//AMI
if (document.form. diagnosis[0].checked)
{
rate = -336.4 + (6.52*weight) + (22*height) - (7.52*age)
}
//USA
else if (document.form. diagnosis[1].checked)
{
rate = -336.4 + (6.52*weight) + (22*height) - (7.52*age) - 142
}
//AFib
else if (document.form. diagnosis[2].checked)
{
rate = -336.4 + (6.52*weight) + (22*height) - 7.52 - 142
}
}
//for females
else if (document.form. gender[1])
{
gender = "female"
//AMI
if (document.form. diagnosis[0].checked)
{
rate = -336.4 + (6.52*weight) + (22*height) + (2.71*age) - 749.2
}
//USA
else if (document.form. diagnosis[1].checked)
{
rate = -336.4 + (6.52*weight) + (22*height) + (2.71*age) - 672.3
}
//AFib
else if (document.form. diagnosis[2].checked)
{
rate = -336.4 + (6.52*weight) + (22*height) + (2.71*age) - 672.3
}
}
//AMI USA or AFib bolus
if (document.form. diagnosis[0] || document.form.d iagnosis[1] ||
document.form.d iagnosis[2])
{
//want bolus
if (document.form. bolus[0].checked)
{
bolus = 50 * weight;
}
//doesn't want bolus
else if (document.form. bolus[1].checked)
bolus = "No Bolus Requested";
}
//DVT and PE bolus and infusion
if (document.form. diagnosis[3].checked)
{
alert("test");
rate = 18 * weight;
//if want bolus
if (document.form. bolus[0].checked)
{
bolus = 80 * weight;
}
//doesn't want bolus
else if (document.form. bolus[1].checked)
bolus = "No Bolus Requested";
}
var pageData;
pageData = "<html><head><m eta http-equiv=\"Content-Type\"
content=\"text/html; charset=iso-8859-1\"><meta name=\"Andrew V.
Romero\" content=\"romer o\"><title>UM C Out of Range Heparin
Protocol</title></head><body background=\"co ctail3.gif\"
link=\"#0000DD\ " vlink=\"#0000DD \" alink=\"#0000DD \"><center><fon t
size=+3>UMC Demo Heparin Protocol</font><font size=+3></font></center>";
pageData = PageData+"<b>Pa tient Data</b><br>Wt: "+weight+"
"+weightUni ts+"    Ht: "+height+"i n    Gender:
"+gender+"<br>< a href=\"index.ht ml\">Back To Form</a>";
alert ("Infusion Rate: "+rate+" units/hr "+gender);
document.write( pageData);
document.close( );
}
else
alert ("Please Fill In All Fields");
}
</script>
<form name="form" method="get" action="" onSubmit=calcul ate();>
<table border =1>
<tr><td colspan=3><b>Pa tient Data</b></td></tr>
<tr><td><b>Weig ht (kg)</b></td><td><input name="weight" size=5><input
type="radio" name="wtUnits" value="kg" checked>Kg   <inpu t
type="radio" name="wtUnits" value="lb">lbs</td></tr>
<tr><td><b>Heig ht (in)</b></td><td><input name="height" size=3></td></tr>
<tr><td><b>Ag e</b></td><td><input name="age" size=3></td></tr>
<tr><td><b>Gend er</b></td><td><input type="radio" name="gender"
value="male" checked>Male    <input type="radio" name="gender"
value="female"> Female</td></tr>
<tr><td><b>Diag nosis</b> </td><td><input type="radio" name="diagnosis "
value="AMI" checked>AMI    <input type="radio" name="diagnosis "
value="USA">USA    <input type="radio" name="diagnosis "
value="AFib">Af ib   <inpu t type="radio" name="diagnosis "
value="DVTorPE" >DVT or PE</td></tr>
<tr><td><b>Bolu s</b></td><td><input type="radio" name="bolus"
value="yes" checked>Yes    <input type="radio" name="bolus"
value="no">No</td></tr>
</table>
<div align=right><br ><input TYPE = "submit" Value = " Calculate
"></div></form>
<hr><br>
</form>
</body>
</html>
Comment