Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

few questions about this code

Status
Not open for further replies.

longmatch

Programmer
Nov 1, 2001
406
Dear Friend:
I wrote this piece of code to verify the data filled on the form. It did popup a message box. But the form was still submitted and went to the another form, whenever I clicked the ok button or cancel button.


Anybody knows how to keep to current page before correction?

Haijun


<script language=&quot;VBScript&quot;>

dim validation

function ProcedureData_onSubmit
validation=true
if not(isdate(document.ProcedureData.dateofProc.value)) then
msgbox &quot;not a correct date format&quot;, 1
validation = false
end if
if validation = true then
ProcedureData_onSubmit=true
else
ProcedueData_onSubmit=false
end if
end function
</Script>
 
<form method=&quot;POST&quot; action=&quot;SomeAction.htm&quot; onSubmit=&quot;return ProcedureData_onSubmit()&quot;>

<p><input type=&quot;submit&quot; value=&quot;Submit&quot; name=&quot;B1&quot;></p>
</form>


<script language=&quot;VBScript&quot;>

function ProcedureData_onSubmit
if not(isdate(document.ProcedureData.dateofProc.value)) then
msgbox &quot;not a correct date format&quot;, 1
ProcedureData_onSubmit = false
else
ProcedureData_onSubmit = true
end if
</Script>
 
To code from above looks fine.
Try to use javascript! If you need code for validation in javascript, just let me know

Durug I was born intelligent - education ruined me. :)
 
First of all,thank you for your helps. I tried this piece of code alone, it works fine. Unfortunately when I added validation code into another ASP page (which is working alone also), the program give me runtime error saying it expected ')'. I took this whole moring, still not fixed. I changed the vbscript code into Javascript, more troubles.

One thing which still confusing me is some code (which is working well) does not work any more when I added some other codes in it.

Please check my code, and help me to fix it. It almost drove me crazy. Thank you very much.

Haijun

<HTML>
<HEAD>
<script language=&quot;VBScript&quot;>

function ProcedureData_onSubmit
if not(isdate(document.ProcedureData.dateofProc.value)) then
msgbox &quot;not a correct date format&quot;, 1
ProcedureData_onSubmit = false
else
ProcedureData_onSubmit = true
end if
</Script>

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!-- Begin
var BehavioralArray = new Array(&quot;('Select Procedure','',true,true)&quot;,
&quot;('Depression, Major')&quot;,
&quot;('Family Counseling')&quot;,
&quot;('Family Management')&quot;,
&quot;('Generalized Anxiety Disorder')&quot;,
&quot;('Individual Consultation')&quot;,
&quot;('Panic Disorder')&quot;,
&quot;('Psychosis, Acute')&quot;,
&quot;('Suicide Tendency')&quot;);
var GYNMArray = new Array(&quot;('Select Procedure','',true,true)&quot;,
&quot;('Abnormal PAPs')&quot;,
&quot;('Dysfunctional Uterine Bleeding')&quot;,
&quot;('Ectopic pregnancy')&quot;,
&quot;('Endometrial cancer')&quot;,
&quot;('Infertility')&quot;,
&quot;('PID')&quot;,
&quot;('Sexual assault')&quot;,
&quot;('Trauma of reproductive system')&quot;);
var GYNPArray = new Array(&quot;('Select Procedure','',true,true)&quot;,
&quot;('Bartholin Duct Cyst Aspiration')&quot;,
&quot;('Bartholin Duct Cyst Marsupialization')&quot;,
&quot;('BTL')&quot;,
&quot;('Cervical Biopsy')&quot;,
&quot;('Colposcopy')&quot;,
&quot;('Cryotherapy')&quot;,
&quot;('Diaphragms Fitting ')&quot;,
&quot;('Dilation Curettage')&quot;,
&quot;('Ectopic management')&quot;,
&quot;('Endometrial Biopsy')&quot;,
&quot;('IUD placement')&quot;,
&quot;('IUD removal')&quot;,
&quot;('Leep')&quot;,
&quot;('Polypectomy')&quot;,
&quot;('Subcutaneous Contraception Implant')&quot;,
&quot;('Subcutaneous Contraception Removal')&quot;,
&quot;('Transvaginal USG')&quot;,
&quot;('Vulvar Lesion Biopsy')&quot;);
var MedicineDArray = new Array(&quot;('Select Procedure','',true,true)&quot;,
&quot;('Acute Abdomen')&quot;,
&quot;('Acute Myocardial Infarction')&quot;,
&quot;('Acute Renal Failure(Medicine DX/Pro)')&quot;,
&quot;('AIDS')&quot;,
&quot;('Asthma Exacerbation')&quot;,
&quot;('CCU-ICU Management')&quot;,
&quot;('Congestive Heart Failure')&quot;,
&quot;('Deep Venous Thrombosis')&quot;,
&quot;('Diabetic Ketoacidosis Management')&quot;,
&quot;('Gastrointestinal Bleeding')&quot;,
&quot;('Pulmonary Edema')&quot;,
&quot;('Pulmonary Embolus')&quot;,
&quot;('Sepsis (Medicine DX/Pro)')&quot;,
&quot;('Shock')&quot;,
&quot;('Stroke')&quot;,
&quot;('Thyroid Storm (Acute thyrotoxicosis)')&quot;);
var MedicinePArray = new Array(&quot;('Select Procedure','',true,true)&quot;,
&quot;('Arterial Line Placement')&quot;,
&quot;('Central Line Placement')&quot;,
&quot;('Flexible Sigmoidoscopy')&quot;,
&quot;('Lumbar Puncture')&quot;,
&quot;('Paracentesis')&quot;,
&quot;('Stress Test ECG')&quot;,
&quot;('Thoracentesis')&quot;);

var OBDArray = new Array(&quot;('Select Procedure','',true,true)&quot;,
&quot;('1st trimester ultrasound')&quot;,
&quot;('2nd trimester ultrasound')&quot;,
&quot;('3rd trimester ultrasound')&quot;,
&quot;('Bleeding in the first trimester')&quot;,
&quot;('Bleeding in the second trimester')&quot;,
&quot;('Bleeding in the third trimester')&quot;,
&quot;('Breastfeeding counseling')&quot;,
&quot;('Chorioamnionitis')&quot;,
&quot;('Postpartum Fever')&quot;,
&quot;('Postpartum Hemorrhage')&quot;,
&quot;('Pregnancy-Induced Hypertension')&quot;,
&quot;('Premature Rupture of Membranes')&quot;,
&quot;('Preterm Labor')&quot;,
&quot;('Resuscitation')&quot;,
&quot;('Shoulder Dystocia')&quot;,
&quot;('Urinary Tract Infection in Pregnancy')&quot;);

var OBPArray = new Array(&quot;('Select Procedure','',true,true)&quot;,
&quot;('Amniotomy')&quot;,
&quot;('Episiotomy ')&quot;,
&quot;('Forceps delivery')&quot;,
&quot;('IUPC placement')&quot;,
&quot;('Labor Induction')&quot;,
&quot;('Normal vaginal delivery')&quot;,
&quot;('Oxytocin for augumentation of labor')&quot;,
&quot;('perineal laceration repair')&quot;,
&quot;('Placement of fetal scalp electrode')&quot;,
&quot;('vacuum delivery')&quot;);

var OrthopedicsArray = new Array(&quot;('Select Procedure','',true,true)&quot;,
&quot;('Arthrocentesis Injection')&quot;,
&quot;('Carpal Tunnel Injury')&quot;,
&quot;('Casting')&quot;,
&quot;('Closed Colles Fracture with Manipulation')&quot;,
&quot;('Closed Colles Fracture without Manipulation')&quot;,
&quot;('Compound Fracture with Surgery')&quot;,
&quot;('Debride (Orthopedics)')&quot;,
&quot;('Dislocation')&quot;,
&quot;('Ganglion Cyst - Aspiration')&quot;,
&quot;('Ortho - Other')&quot;,
&quot;('Shoulder Immobilization')&quot;);

var PediatricsNArray = new Array(&quot;('Select Procedure','',true,true)&quot;,
&quot;('ABGs (Pediatric/Neonatal)')&quot;,
&quot;('Chest Tube (Pediatric/Neonatal)')&quot;,
&quot;('Circumcision (Pediatric/Neonatal)')&quot;,
&quot;('CPR (Pediatric/Neonatal)')&quot;,
&quot;('Exchange Transfusion (Pediatric/Neonatal)')&quot;,
&quot;('IV Place (Pediatric/Neonatal)')&quot;,
&quot;('LP (Pediatric/Neonatal)')&quot;,
&quot;('PED/NEO - Other (Precedural)')&quot;,
&quot;('Supra Pub Bld Aspiration (Pediatric/Neonatal)')&quot;,
&quot;('UmbilCath -A (Pediatric/Neonatal)')&quot;,
&quot;('UmbilCath -V (Pediatric/Neonatal)')&quot;,
&quot;('Venipuncture (Pediatric/Neonatal)')&quot;);


var SurgeryArray = new Array(&quot;('Select Procedure','',true,true)&quot;,
&quot;('Appendectomy')&quot;,
&quot;('Biopsy/Skin-Excision')&quot;,
&quot;('Biopsy/Skin-Punch-Shave')&quot;,
&quot;('Chalazion Excision')&quot;,
&quot;('Cryotherapy Treatment - Warts')&quot;,
&quot;('Debridement')&quot;,
&quot;('Foreign Body Removal')&quot;,
&quot;('Foreign Body Removal-Eye')&quot;,
&quot;('Hemorrhoid Banding')&quot;,
&quot;('Hickman Catheter')&quot;,
&quot;('Incision and Drainage - Other')&quot;,
&quot;('Incision and Drainage - PeriRectal')&quot;,
&quot;('Incision and Drainage - Pilonidal')&quot;,
&quot;('Laceration - Complex')&quot;,
&quot;('Laceration - Eyelid')&quot;,
&quot;('Laceration - Simple')&quot;,
&quot;('Nail Removal')&quot;,
&quot;('Surg - Other')&quot;,
&quot;('Trauma, Head')&quot;,
&quot;('Trauma, Multiple')&quot;,
&quot;('Unlisted Procedure')&quot;,
&quot;('Vasectomy')&quot;);

function populateProcedure(inForm,selected) {
var selectedArray = eval(selected + &quot;Array&quot;);
while (selectedArray.length < inForm.Procedure.options.length) {
inForm.Procedure.options[(inForm.Procedure.options.length - 1)] = null;
}
for (var i=0; i < selectedArray.length; i++) {
eval(&quot;inForm.Procedure.options=&quot; + &quot;new Option&quot; + selectedArray);
}
if (inForm.Category.options[0].value == '') {
inForm.Category.options[0]= null;
if ( navigator.appName == 'Netscape') {
if (parseInt(navigator.appVersion) < 4) {
window.history.go(0);
}
else {
if (navigator.platform == 'Win32' || navigator.platform == 'Win16') {
window.history.go(0);
}
}
}
}
}
function populateUSstate(inForm,selected) {
var stateArray = new Array(&quot;('Select State','',true,true)&quot;,
&quot;('Alabama')&quot;,
&quot;('Alaska')&quot;,
&quot;('Arizona')&quot;,
&quot;('Arkansas')&quot;,
&quot;('California')&quot;,
&quot;('Colorado')&quot;,
&quot;('Connecticut')&quot;,
&quot;('Delaware')&quot;,
&quot;('Columbia')&quot;,
&quot;('Florida')&quot;,
&quot;('Georgia')&quot;,
&quot;('Hawaii')&quot;,
&quot;('Idaho')&quot;,
&quot;('Illinois')&quot;,
&quot;('Indiana')&quot;,
&quot;('Iowa')&quot;,
&quot;('Kansas')&quot;,
&quot;('Kentucky')&quot;,
&quot;('Louisiana')&quot;,
&quot;('Maine')&quot;,
&quot;('Maryland')&quot;,
&quot;('Massachusetts')&quot;,
&quot;('Michigan')&quot;,
&quot;('Minnesota')&quot;,
&quot;('Mississippi')&quot;,
&quot;('Missouri')&quot;,
&quot;('Montana')&quot;,
&quot;('Nebraska')&quot;,
&quot;('Nevada')&quot;,
&quot;('New Hampshire')&quot;,
&quot;('New Jersey')&quot;,
&quot;('New Mexico')&quot;,
&quot;('New York')&quot;,
&quot;('North Carolina')&quot;,
&quot;('North Dakota')&quot;,
&quot;('Ohio')&quot;,
&quot;('Oklahoma')&quot;,
&quot;('Oregon')&quot;,
&quot;('Pennsylvania')&quot;,
&quot;('Rhode Island')&quot;,
&quot;('South Carolina')&quot;,
&quot;('South Dakota')&quot;,
&quot;('Tennessee')&quot;,
&quot;('Texas')&quot;,
&quot;('Utah')&quot;,
&quot;('Vermont')&quot;,
&quot;('Virginia')&quot;,
&quot;('Washington')&quot;,
&quot;('West Virginia')&quot;,
&quot;('Wisconsin')&quot;,
&quot;('Wyoming')&quot;);
if (selected == 'USA') {
for (var i=0; i < stateArray.length; i++) {
eval(&quot;inForm.Procedure.options=&quot; + &quot;new Option&quot; + stateArray);
}
if ( navigator.appName == 'Netscape') {
if (parseInt(navigator.appVersion) < 4) {
window.history.go(0)
}
else {
if (navigator.platform == 'Win32' || navigator.platform == 'Win16') {
window.history.go(0)
}
}
}
}
else {
}
if (selected == 'Other') {
newProcedure = &quot;&quot;;
while (newProcedure == &quot;&quot;){
newProcedure=prompt (&quot;Please enter the name of your Procedure.&quot;, &quot;&quot;);
}
if (newProcedure != null) {
inForm.Procedure.options[(inForm.Procedure.options.length-1)]=new Option(newProcedure,newProcedure,true,true);
inForm.Procedure.options[inForm.Procedure.options.length]=new Option('Other, not listed','Other');
}
}
if(inForm.Procedure.options[0].text == 'Select Procedure') {
inForm.Procedure.options[0]= null;
}
}
// End -->
</script>


<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<TITLE></TITLE>
</HEAD>
<BODY bgcolor=GreenYellow>

<form Name=&quot;ProcedureData&quot; method=post onSubmit=&quot;return ProcedureData_onSubmit()&quot;>
<TABLE WIDTH=60% BORDER=1 CELLSPACING=1 CELLPADDING=1 align=center
bgcolor=LightSkyBlue>
<TR>
<TD>Date of Procedure</TD>
<TD><INPUT type=&quot;text&quot; id=text1 name=DateofProc value =&quot;<%= session(&quot;DateofProc&quot;)%>&quot; size=&quot;40&quot;></TD>
</TR>

<script language=JScript>
document.ProcedureData.DateofProc.Value=&quot;1/1/1999&quot;
</script>
<TR>
<TD><b>Resident Information</b></TD>
<TD></TD>
</TR>
<TR>
<TD>Resident Name</TD>
<TD><SELECT size=1 id=select1 name=ResidentName VALUE=&quot;<%= session(&quot;ResidentName&quot;)%>&quot; >
<OPTION>?</OPTION>
<OPTION>Cardarelli, Robert</OPTION>
<OPTION>De Leon, Berta</OPTION>
<option>Lee, William</option>
</SELECT></TD></TR>
<TR>
<TD>Rotation Location</TD>
<TD><SELECT size=1 id=select2 name=Rotation VALUE=&quot;<%= session(&quot;Rotation&quot;)%>&quot;>
<option>?/option>
<option>Family Medicine In-patient Service 3--NW</option>
<option>Family Medicine Orientation</option>
<option>Family Practice Center--BFM</option>
<option>Family Practice Center--Kelsey-Seybold</option>
<option>Family Practice Center--Northwest</option>
<option>Family Psychology</option>
<option>General Medicine Wards</option>
<option>General Surgery</option>
<option>Geriatric - Nursing Home</option>
<option>Geriatrics--Outpatient</option>
<option>Gynecology</option>
<option>Medical Intensive Care Unit</option>
<option>Neonatology</option>
<option>Neurology</option>
<option>Obstetrics Triage</option>
<option>Obstetrics--Night Call</option>
<option>Obstetrics--Night Call & Obstetrics Triage</option>
<option>Ophthalmology</option>
<option>Orthopedics</option>
<option>Pediatric ER</option>
<option>Pediatric Sub-specialty</option>
<option>Pediatric Ward</option>
<option>Pediatrics, Ambulatory</option>
<option>Pediatrics, Inpatient</option>
<option>Sports Medicine</option>
<option>Surgery ER</option>
<option>Urology</option>
<option>Women's Health--Gyn</option>
<option>Women's Health--OB</option>
<option>Women's Health--OB/Gyn</option>

</SELECT></TD>
</TR>
<TR>
<TD><b>Patient information</b></TD>
<TD></TD>
</TR>
<TR>
<TD>Patient First Name</TD>
<TD><INPUT type=&quot;text&quot; id=text4 name=PtFirstName VALUE=&quot;<%= session(&quot;PtFirstName&quot;)%>&quot;></TD>
</TR>
<TR>
<TD>Patient Last Name</TD>
<TD><INPUT type=&quot;text&quot; id=text2 name=PtLastName VALUE=&quot;<%= session(&quot;PtLastName&quot;)%>&quot; ></TD>
</TR>
<TR>
<TD>Date of Birth</TD>
<TD><INPUT type=&quot;text&quot; id=text3 name=DOB VALUE=&quot;<%= session(&quot;DOB&quot;)%>&quot;></TD>
</TR>
<TR>
<TD>Sex</TD>
<TD><SELECT size=1 id=select3 name=Sex VALUE=&quot;<%= session(&quot;Sex&quot;)%>&quot;>
<option>?/option>
<OPTION>Male</OPTION>
<OPTION>Female</OPTION>
</SELECT></TD>
</TR>
<TR>
<TD>Location</TD>
<TD><SELECT size=1 id=select4 name=Location VALUE=&quot;<%= session(&quot;Locatioin&quot;)%>&quot;>
<option>?/option>
<OPTION>Seven Acres Nursing Home</OPTION>
<OPTION>Advance Credit Given</OPTION>
<OPTION>Antoine Clinic</OPTION>
<OPTION>Baylor Family Medicine</OPTION>
<OPTION>Ben Taub General Hospital</OPTION>
<OPTION>Casa de Amigos</OPTION>
<OPTION>Gulfgate Health Center</OPTION>
<OPTION>MLK Health Center</OPTION>
<OPTION>Northwest Health Center</OPTION>
<OPTION>People's Health Center</OPTION>
<OPTION>Strawberry Health Center</OPTION>
<OPTION>International</OPTION>
<OPTION>Kelsey Seybold</OPTION>
<OPTION>The Lord of the Streets</OPTION>
<OPTION>M.D. Anderson Cencer Center</OPTION>
<OPTION>Methodist Hospital</OPTION>
<OPTION>Nursing Home--Other</OPTION>
<OPTION>Private Practice</OPTION>
<OPTION>Quentin Meese</OPTION>
<OPTION>Rural Practice</OPTION>
<OPTION>S.E.A.R.C.H. Homeless Clinic</OPTION>
<OPTION>Saint Luke's Episcopal Hospital</OPTION>
<OPTION>Star of Hope</OPTION>
<OPTION>Texas Childrens' Hospital</OPTION>
<OPTION>Thomas Street Clinic</OPTION>
<OPTION>Veterans Affairs Medical Center</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD>Medical Record No</TD>
<TD><INPUT type=&quot;text&quot; id=text5 name=MedRedNo VALUE=&quot;<%= session(&quot;MedRedNo&quot;)%>&quot;></TD>
</TR>
<TR>
<TD>continuity Patient</TD>
<TD><INPUT type=&quot;checkbox&quot; id=checkbox1 name=Continuity VALUE=&quot;<%= session(&quot;Continuity&quot;)%>&quot;></TD>
</TR>
<TR>
<TD><B>Procedure Information</B></TD>
<TD></TD>
</TR>
<TR>
<TD>Category</TD>
<TD><select name=&quot;Category&quot; onChange=&quot;populateProcedure(document.ProcedureData,document.ProcedureData.Category.options[document.ProcedureData.Category.selectedIndex].value)&quot;>
<option selected value=''>Select Category</option>
<option value='Behavioral'>Behavioral Science</option>
<option value='GYNM'>GYN Management</option>
<option value='GYNP'>GYN Procedures</option>
<option value='MedicineD'>Medicine Diagnosis</option>
<option value='MedicineP'>Medicine Procedures</option>
<option value='OBD'>OB Diagnosis/Management</option>
<option value='OBP'>OB Procedures</option>
<option value='Orthopedics'>Orthopedics</option>
<option value='PediatricsN'>Pediatrics/Neonatal</option>
<option value='Surgery'>Surgery</option>
</select></TD>
<TR>
<TD>Procedure</TD>
<TD><select name=&quot;Procedure&quot; onChange=&quot;populateUSstate(document.ProcedureData,document.ProcedureData.Procedure.options[document.ProcedureData.Procedure.selectedIndex].text)&quot;>
<option value=''><--------------------</option>
</select></TD>
</TR>




<TR>
<TD>Involment</TD>
<TD><SELECT size=1 id=select7 name=Involvement VALUE=&quot;<%= session(&quot;Involvement&quot;)%>&quot;>
<option>?/option>
<OPTION>Assisted</OPTION>
<OPTION>Performed</OPTION>
<OPTION>Supervised</OPTION>
<OPTION>Independent Performance</OPTION>
</SELECT></TD>
</TR>
<TR>
<TD>Topic category</TD>
<TD><SELECT size=1 id=select8 name=TopicCategory VALUE=&quot;<%= session(&quot;TopicCategory&quot;)%>&quot;>
<option>?/option>
<OPTION>New Problem</OPTION>
<OPTION>Check-up</OPTION>
<OPTION>Chronic Illness</OPTION>
<OPTION>Psychological</OPTION>
<OPTION>Behavior Change</OPTION>
</SELECT></TD>
</TR>
<TR>
<TD>Did you follow the TOPIC model?</TD>
<TD><INPUT type=&quot;checkbox&quot; id=checkbox2 name=didYouFollowTheTopicModel VALUE=&quot;<%= session(&quot;didYouFollowTheTopicModel&quot;)%>&quot;></TD>
</TR>
<TR>
<TD>Supervisor</TD>
<TD><INPUT type=&quot;text&quot; id=text6 name=Supervisor VALUE=&quot;<%= session(&quot;Supervisor&quot;)%>&quot;></TD>
</TR>
<TR>
<TD>Other information</TD>
<TD><TEXTAREA rows=2 cols=20 id=textarea1 name=OtherInfo VALUE=&quot;<%= session(&quot;OtherInfo&quot;)%>&quot;>
</TEXTAREA></TD>
</TR>
<TR>
<TD>Faculty in charge</TD>
<TD><INPUT type=&quot;text&quot; id=text7 name=FacultyIncharge VALUE=&quot;<%= session(&quot;FacultyInCharge&quot;)%>&quot;></TD>
</TR>
<TR>
<TD>Observed by</TD>
<TD><SELECT size=1 id=select9 name=ObservedBy VALUE=&quot;<%= session(&quot;ObservedBy&quot;)%>&quot;>
<option>?/option>
<OPTION>Faculty Memeber</OPTION>
<OPTION>Upper Level Resident</OPTION>
<OPTION>Other</OPTION>
</SELECT></TD>
</TR>
<TR>
<TD>Comments</TD>
<TD><TEXTAREA rows=2 cols=20 id=textarea2 name=Comments VALUE=&quot;<%= session(&quot;Comments&quot;)%>&quot;>
</TEXTAREA></TD>
</TR>
<TR>
<TD>Other procedure?</TD>
<TD><INPUT type=&quot;checkbox&quot; id=checkbox3 name=AotherProcedure VALUE=&quot;<%= session(&quot;AnotherProcedure&quot;)%>&quot;></TD>
</TR>
<TR>
<TD><INPUT type=&quot;submit&quot; value=&quot;Submit Your Procedure&quot; id=submit1 name=submit1></TD>
<TD><INPUT type=&quot;reset&quot; value=&quot;Reset&quot; id=reset1 name=reset1></TD>

</TABLE>

</form>
</BODY>
</HTML>
 
Just on first look:
1.
<script language=&quot;VBScript&quot;>

function ProcedureData_onSubmit
if not(isdate(document.ProcedureData.dateofProc.value)) then
msgbox &quot;not a correct date format&quot;, 1
ProcedureData_onSubmit = false
else
ProcedureData_onSubmit = true
end if
<---- End Function missing
</Script>

2.select name=&quot;Category&quot; onChange=&quot;populateProcedure(document.ProcedureData,document.ProcedureData.Category.options[document.ProcedureData.Category.selectedIndex].value)&quot;>

missing: onchange=&quot;javascript:populate... selectedIndex].value;&quot;

3. the same with this one
select name=&quot;Procedure&quot; onChange=&quot;javascript:populateUSstate(document.ProcedureData,document.ProcedureData.Procedure.options[document.ProcedureData.Procedure.selectedIndex].text);&quot;>

But at least the page is loading without any error.
I will keep looking
 
Dear Durug:
I deleted the &quot;end function&quot; accidentally when I was working on this code. I can not understand what mean &quot;missing: ononchange=&quot;javascript:populate... selectedIndex].value;&quot;. This code worked fine without validation code. How can I make it work?

need further help


Thank you

Haijun
 
Your code was:

select name=&quot;Procedure&quot; onChange=&quot;populateUSstate(document.ProcedureData,document.ProcedureData.Procedure.options[document.ProcedureData.Procedure.selectedIndex].text)&quot;>

In my browser I got an error on this line
so, if you change it to:
select name=&quot;Procedure&quot; onChange=&quot;javascript:populateUSstate(document.ProcedureData,document.ProcedureData.Procedure.options[document.ProcedureData.Procedure.selectedIndex].text);&quot;>

I'm not getting an error when I load the page, I'm getting the error calling the function.
I will keep looking

Regards,
Durug
 
Hi Longmatch

Some things I have noticed are

1)Missing double brackets on the function
function ProcedureData_onSubmit
should be
function ProcedureData_onSubmit()

2)As durug pointed out, the end function was missing.
I was writting on the fly and must have left it out
of my last posting - sorry.

3)make sure semi-collens are included when calling
JavaScript functions.
onChange=&quot;populateProcedure(...., ....[....]...);&quot;>

also

I don't believe you need to include the word option.
example:
try changing from
document.ProcedureData.Category.option[...].value);
to
document.ProcedureData.Category[...].value);


4)Since this is an asp page and I have not run this on
a server I have not tested that the sessions work, but
while I am not 100% sure on this I think you want to
use something like the following when writting session
info to the textboxes

Value=&quot; <% response.write(session(name)) %>
OR
<%response.write(&quot;Value='&quot; & session(name) & &quot;' >&quot;) %>

5)Try moving all your scripts below your HTML code.

example:
<HTML>
<BODY>
Regular HTML code in here
</BODY>
</HTML>

<Script Language = &quot;VBSCRIPT&quot;>
VBScript code here
</SCRIPT>

<Script Language = &quot;JAVASCRIPT&quot;>
JAVAScript code here
</SCRIPT>



 
Dear KevinClark:

After I moved the script codes below my html code, it works. Could you tell me why.
It will be bothering with your help.
I also give my special thanks also Durug, your suggestions are valuable.

Thank you very much


Haijun
 
Hi Longmatch

This is a bit of a guess but I believe it has to do with the timing or sequence that the script interpreters are loaded and run. It's possible that the locations of the JavaScript and VBScript along with loading sequence or timing of the interpreters may have been causing some problems / confussion for the interpreters. If you place the code at the bottom of the page as I asked you to try, then I believe the above HTML sections should be loaded by the browser before the interpreters load and run. The acception would be if we are using the code to insert something like a date or time into the HTML page.

I think durug deserves the thanks for this one as it was his suggestion regarding adding the JavaScript: to places that were calling the JavaScript functions that led me to make my suggestion. While I have never had call to do what he suggested, I figured if my guess was right that a simple cut and paste may save you some typing.
 
kevinclark,
thanks, you are very polite. It doesn't matter who found the solution, important is that longmatch solved his problem.

Regards,
Durug
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top