Appreciate any ideas..I'm sure the problem is simple, but I cannot seem to find a solution.
The following code uses a simple form for the user to input data, and I'm attempting to use a function I created, the CheckData() function, to force the user to have to input a first and last name before they can move onto any other fields to input data.
The problem I'm running into is that the alert window pops up, reminding the user he or she must input their name information, but I get locked into the popup and cannot shut it down. It seems to work fine whenever I move to any other fields, but the input data fields for first and last name lock up. mmmm?
Please take a look at the code, anyone, and let me know what I might do to make this function work. Appreciate it.
--------------------
<HTML>
<HEAD>
<SCRIPT>
<!-- Hide from older browsers
function DateToday() {
var Today=new Date();
var ThisDay=Today.getDate();
var ThisMonth=Today.getMonth()+1;
var ThisYear=Today.getFullYear();
return ThisMonth+"/"+ThisDay+"/"+ThisYear;
}
function StartForm() {
document.REG.FORMDATE.value=DateToday();
document.REG.FIRSTNAME.focus();
}
function CheckOther() {
if(document.REG.PHYSICIAN.selectedIndex==7) {
document.REG.OTHERNAME.value=prompt("Enter name of physician", "Name"
;
}
document.REG.ACT.focus();
}
function APGAR(field) {
if(field.value==0 || field.value==1 || field.value==2) {
var A=eval(document.REG.ACT.value);
var P=eval(document.REG.PULSE.value);
var G=eval(document.REG.GRIMACE.value);
var AP=eval(document.REG.APP.value);
var R=eval(document.REG.RESP.value);
document.REG.TOTAL.value=A+P+G+AP+R;
} else {
alert("You must enter a 0, 1, or 2"
;
field.focus();
}
}
function Check_Data() {
if(document.REG.CONSENT.checked==true) {
alert("Form completed successfully"
;
return true;
} else {
alert("You still need parental consent"
;
return false;
}
}
function Check_Field(field) {
if(field.value==""
{
alert("You must enter a first and last name."
;
field.focus();
}
}
//Stop hiding -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#008080" TEXT=WHITE onLoad="StartForm();">
<FORM NAME=REG onSubmit="return Check_Data();">
<CENTER>
<IMG SRC="Logo.gif" WIDTH=450 HEIGHT=75 ALT="St. Marys of Northland Pines">
<TABLE CELLSPACING=3 CELLPADDING=5>
<!--- Study Title--->
<TR>
<TD ALIGN=CENTER COLSPAN=3>
<H1><FONT FACE="Arial,Helvetica">Neonatal Feeding Study</FONT></H1>
</TD>
</TR>
<!--- Field showing the current date --->
<TR>
<TD COLSPAN=3 ALIGN=RIGHT>
Date: <INPUT NAME=FORMDATE SIZE=10 MAXLENGTH=10>
</TD>
</TR>
<!--- Fields containing the first and last name of the patient --->
<TR>
<TD>
1) Name (first, last):
</TD>
<TD>
<INPUT NAME=FIRSTNAME onBlur="Check_Field(this);">
</TD>
<TD>
<INPUT NAME=LASTNAME onBlur="Check_Field(this);">
</TD>
</TR>
<!--- Medical record number field --->
<TR>
<TD>
2) Medical Record #:
</TD>
<TD>
<INPUT NAME=MEDRECNO SIZE=10 MAXLENGTH=10 onBlur="Check_Field(this);">
</TD>
</TR>
<!--- Date of birth field --->
<TR>
<TD>
3) Date of birth:
</TD>
<TD>
<INPUT NAME=DOB VALUE="mm/dd/yyyy" SIZE=10 MAXLENGTH=10>
</TD>
</TR>
<!--- Selection list with physician names and a field for names not in list --->
<TR>
<TD>
4) Physician:
</TD>
<TD>
<SELECT NAME=PHYSICIAN onBlur="CheckOther();">
<OPTION VALUE="Albert">Dr. Warren Albert
<OPTION VALUE="Alvarez">Dr. Maria Alvarez
<OPTION VALUE="Brinkman">Dr. Karen Brinkman
<OPTION VALUE="Kerry">Dr. Michael Kerry
<OPTION VALUE="Nichols">Dr. Chad Nichols
<OPTION VALUE="Paulson">Dr. Karen Paulson
<OPTION VALUE="Webb">Dr. Tai Webb
<OPTION VALUE="Other">Other
</SELECT>
</TD>
</TR>
<!--- Physician names not in the list --->
<TR>
<TD>
If other (specify):
</TD>
<TD>
<INPUT NAME=OTHERNAME>
</TD>
</TR>
<!--- Activity component of the APGAR score --->
<TR>
<TD ROWSPAN=6 VALIGN=TOP>
5) 1 Minute APGAR Score:
</TD>
<TD>
Activity
</TD>
<TD>
<INPUT NAME=ACT VALUE=0 SIZE=1 MAXLENGTH=1 onBlur="APGAR(this);">
</TD>
</TR>
<!--- Pulse component of the APGAR score --->
<TR>
<TD>
Pulse
</TD>
<TD>
<INPUT NAME=PULSE VALUE=0 SIZE=1 MAXLENGTH=1 onBlur="APGAR(this);">
</TD>
</TR>
<!--- Grimace component of the APGAR score --->
<TR>
<TD>
Grimace (Reflex, Irritability)
</TD>
<TD>
<INPUT NAME=GRIMACE VALUE=0 SIZE=1 MAXLENGTH=1 onBlur="APGAR(this);">
</TD>
</TR>
<!--- Appearance component of the APGAR score --->
<TR>
<TD>
Appearance (Skin Color)
</TD>
<TD>
<INPUT NAME=APP VALUE=0 SIZE=1 MAXLENGTH=1 onBlur="APGAR(this);">
</TD>
</TR>
<!--- Respiration component of the APGAR score --->
<TR>
<TD>
Respiration
</TD>
<TD>
<INPUT NAME=RESP VALUE=0 SIZE=1 MAXLENGTH=1 onBlur="APGAR(this);">
</TD>
</TR>
<!--- Total APGAR score --->
<TR>
<TD>
<B>TOTAL</B>
</TD>
<TD>
<INPUT NAME=TOTAL VALUE=0 SIZE=2 MAXLENGTH=2>
</TD>
</TR>
<!--- Birth weight field --->
<TR>
<TD>
6) Birth weight (gms):
</TD>
<TD>
<INPUT NAME=BWGT SIZE=6 onBlur="Check_Field(this);">
</TD>
</TR>
<!--- Parental consent checkbox --->
<TR>
<TD>
7) Parental Consent (required):
</TD>
<TD>
<INPUT TYPE=CHECKBOX NAME=CONSENT>
</TD>
</TR>
<!--- Form registration and reset buttons --->
<TR>
<TD COLSPAN=3 ALIGN=CENTER>
<INPUT TYPE=SUBMIT VALUE="Register">
<INPUT TYPE=RESET VALUE="Reload" onClick="location.reload();">
</TD>
</TR>
</TABLE>
</CENTER>
<P>Please submit all questions regarding this form or the NICU feeding study
to <FONT COLOR="#FFFF00">Dr. Karen Paulson, Department of Pediatrics, ext.
5122</FONT>.</P>
</FORM>
</BODY>
</HTML>
Christopher "Cloudy" Headrick
Chief Operations Officer
Recon Networks, Inc.
Web:
The following code uses a simple form for the user to input data, and I'm attempting to use a function I created, the CheckData() function, to force the user to have to input a first and last name before they can move onto any other fields to input data.
The problem I'm running into is that the alert window pops up, reminding the user he or she must input their name information, but I get locked into the popup and cannot shut it down. It seems to work fine whenever I move to any other fields, but the input data fields for first and last name lock up. mmmm?
Please take a look at the code, anyone, and let me know what I might do to make this function work. Appreciate it.
--------------------
<HTML>
<HEAD>
<SCRIPT>
<!-- Hide from older browsers
function DateToday() {
var Today=new Date();
var ThisDay=Today.getDate();
var ThisMonth=Today.getMonth()+1;
var ThisYear=Today.getFullYear();
return ThisMonth+"/"+ThisDay+"/"+ThisYear;
}
function StartForm() {
document.REG.FORMDATE.value=DateToday();
document.REG.FIRSTNAME.focus();
}
function CheckOther() {
if(document.REG.PHYSICIAN.selectedIndex==7) {
document.REG.OTHERNAME.value=prompt("Enter name of physician", "Name"
}
document.REG.ACT.focus();
}
function APGAR(field) {
if(field.value==0 || field.value==1 || field.value==2) {
var A=eval(document.REG.ACT.value);
var P=eval(document.REG.PULSE.value);
var G=eval(document.REG.GRIMACE.value);
var AP=eval(document.REG.APP.value);
var R=eval(document.REG.RESP.value);
document.REG.TOTAL.value=A+P+G+AP+R;
} else {
alert("You must enter a 0, 1, or 2"
field.focus();
}
}
function Check_Data() {
if(document.REG.CONSENT.checked==true) {
alert("Form completed successfully"
return true;
} else {
alert("You still need parental consent"
return false;
}
}
function Check_Field(field) {
if(field.value==""
alert("You must enter a first and last name."
field.focus();
}
}
//Stop hiding -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#008080" TEXT=WHITE onLoad="StartForm();">
<FORM NAME=REG onSubmit="return Check_Data();">
<CENTER>
<IMG SRC="Logo.gif" WIDTH=450 HEIGHT=75 ALT="St. Marys of Northland Pines">
<TABLE CELLSPACING=3 CELLPADDING=5>
<!--- Study Title--->
<TR>
<TD ALIGN=CENTER COLSPAN=3>
<H1><FONT FACE="Arial,Helvetica">Neonatal Feeding Study</FONT></H1>
</TD>
</TR>
<!--- Field showing the current date --->
<TR>
<TD COLSPAN=3 ALIGN=RIGHT>
Date: <INPUT NAME=FORMDATE SIZE=10 MAXLENGTH=10>
</TD>
</TR>
<!--- Fields containing the first and last name of the patient --->
<TR>
<TD>
1) Name (first, last):
</TD>
<TD>
<INPUT NAME=FIRSTNAME onBlur="Check_Field(this);">
</TD>
<TD>
<INPUT NAME=LASTNAME onBlur="Check_Field(this);">
</TD>
</TR>
<!--- Medical record number field --->
<TR>
<TD>
2) Medical Record #:
</TD>
<TD>
<INPUT NAME=MEDRECNO SIZE=10 MAXLENGTH=10 onBlur="Check_Field(this);">
</TD>
</TR>
<!--- Date of birth field --->
<TR>
<TD>
3) Date of birth:
</TD>
<TD>
<INPUT NAME=DOB VALUE="mm/dd/yyyy" SIZE=10 MAXLENGTH=10>
</TD>
</TR>
<!--- Selection list with physician names and a field for names not in list --->
<TR>
<TD>
4) Physician:
</TD>
<TD>
<SELECT NAME=PHYSICIAN onBlur="CheckOther();">
<OPTION VALUE="Albert">Dr. Warren Albert
<OPTION VALUE="Alvarez">Dr. Maria Alvarez
<OPTION VALUE="Brinkman">Dr. Karen Brinkman
<OPTION VALUE="Kerry">Dr. Michael Kerry
<OPTION VALUE="Nichols">Dr. Chad Nichols
<OPTION VALUE="Paulson">Dr. Karen Paulson
<OPTION VALUE="Webb">Dr. Tai Webb
<OPTION VALUE="Other">Other
</SELECT>
</TD>
</TR>
<!--- Physician names not in the list --->
<TR>
<TD>
If other (specify):
</TD>
<TD>
<INPUT NAME=OTHERNAME>
</TD>
</TR>
<!--- Activity component of the APGAR score --->
<TR>
<TD ROWSPAN=6 VALIGN=TOP>
5) 1 Minute APGAR Score:
</TD>
<TD>
Activity
</TD>
<TD>
<INPUT NAME=ACT VALUE=0 SIZE=1 MAXLENGTH=1 onBlur="APGAR(this);">
</TD>
</TR>
<!--- Pulse component of the APGAR score --->
<TR>
<TD>
Pulse
</TD>
<TD>
<INPUT NAME=PULSE VALUE=0 SIZE=1 MAXLENGTH=1 onBlur="APGAR(this);">
</TD>
</TR>
<!--- Grimace component of the APGAR score --->
<TR>
<TD>
Grimace (Reflex, Irritability)
</TD>
<TD>
<INPUT NAME=GRIMACE VALUE=0 SIZE=1 MAXLENGTH=1 onBlur="APGAR(this);">
</TD>
</TR>
<!--- Appearance component of the APGAR score --->
<TR>
<TD>
Appearance (Skin Color)
</TD>
<TD>
<INPUT NAME=APP VALUE=0 SIZE=1 MAXLENGTH=1 onBlur="APGAR(this);">
</TD>
</TR>
<!--- Respiration component of the APGAR score --->
<TR>
<TD>
Respiration
</TD>
<TD>
<INPUT NAME=RESP VALUE=0 SIZE=1 MAXLENGTH=1 onBlur="APGAR(this);">
</TD>
</TR>
<!--- Total APGAR score --->
<TR>
<TD>
<B>TOTAL</B>
</TD>
<TD>
<INPUT NAME=TOTAL VALUE=0 SIZE=2 MAXLENGTH=2>
</TD>
</TR>
<!--- Birth weight field --->
<TR>
<TD>
6) Birth weight (gms):
</TD>
<TD>
<INPUT NAME=BWGT SIZE=6 onBlur="Check_Field(this);">
</TD>
</TR>
<!--- Parental consent checkbox --->
<TR>
<TD>
7) Parental Consent (required):
</TD>
<TD>
<INPUT TYPE=CHECKBOX NAME=CONSENT>
</TD>
</TR>
<!--- Form registration and reset buttons --->
<TR>
<TD COLSPAN=3 ALIGN=CENTER>
<INPUT TYPE=SUBMIT VALUE="Register">
<INPUT TYPE=RESET VALUE="Reload" onClick="location.reload();">
</TD>
</TR>
</TABLE>
</CENTER>
<P>Please submit all questions regarding this form or the NICU feeding study
to <FONT COLOR="#FFFF00">Dr. Karen Paulson, Department of Pediatrics, ext.
5122</FONT>.</P>
</FORM>
</BODY>
</HTML>
Christopher "Cloudy" Headrick
Chief Operations Officer
Recon Networks, Inc.
Web: