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!

how to bring data back to original form for editing?

Status
Not open for further replies.

longmatch

Programmer
Nov 1, 2001
406
I used a form for data input. Sometimes users need to go back to edit their data when they found there is error in data input. How to do this?

Haijun
 
You retrieve the relevant data from the database and insert it as VALUE-attributes of the form fields.
That is: If your form contains TEXTAREAs the content from the db goes between the opening and the closing tags. This is not a bug - it's an undocumented feature...
;-)
 
If you show me your form-code and your sql/db code, I can be more specific This is not a bug - it's an undocumented feature...
;-)
 
Please find my form code, it is a little bit longer. As for the datbase code, I will give you in next reply.

Thanks

Haijun

Form code.

<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<TITLE>Procedure collection data </TITLE>
</HEAD>
<BODY bgcolor=GreenYellow>
<form Name=&quot;ProcedureData&quot; method=&quot;post&quot; Action = AddNewData.asp onsubmit= &quot;return validation();&quot; language=&quot;jscript&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;></TD>
</TR>
<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=<%= session(&quot;Continuity&quot;)%>></TD>
</TR>
<TR>
<%
if Request.Form(&quot;continuity&quot;).value = checked then

%>

<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;>
<option value=''><--------------------</option>
</select></TD>
</TR>




<TR>
<TD>Involvement</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>

</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>
<input type=hidden name=&quot;required&quot; value=&quot;DateofProc,ResidentName,Rotation, PtFirstName, PtLastName, DOB, Sex, Location, & _
MedRedNo, Continuity, Category, Procedure1, Involvement&quot;>
</TABLE>

</form>
</BODY>
</HTML>

<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);
}
}
}
}
}

// End -->
</script>

<script language=&quot;vbscript&quot;>
<!--
function validation()
if not(isdate(document.ProcedureData.dateofProc.value)) then
msgbox &quot;not a correct date format&quot;, 1
validation = false
else
validation = true
end if

if not(isdate(document.ProcedureData.DOB.value)) then
msgbox &quot;Please enter correct date format&quot;, 1
validation = false
else
validation = true
end if

if not(isNumeric(document.ProcedureData.MedRedNo.value)) then
msgbox &quot; Medical Record should be a number&quot;, 1
validation = false
else
validation = true
end if
end function

if document.ProcedureData.continuity.value = true then
continuity = true
else
continuity = false
end if

-->
</script>

 
My database code is here.
<!-- METADATA TYPE=&quot;typelib&quot;
FILE=&quot;C:\Program Files\Common Files\System\ado\Msado15.dll&quot; -->

<%@ Language = &quot;VBScript&quot;%>
<%
'Declare all local variables

dim conn
dim rs
dim strID
dim strconn



'set a local variable to my DSN-less connection String
strconn = &quot;DRIVER=Microsoft Access Driver (*.mdb);DBQ=&quot; & Server.MapPath(&quot;ProcedureData.mdb&quot;)

'Create the Connection object
set conn = server.createobject(&quot;adodb.connection&quot;)
conn.open strconn


'Create the recordset object
set rs = server.createobject(&quot;adodb.recordset&quot;)
'This statement opens the table so we can add a record notice the addnew
'The 2, 2 is how the table is opened there are many ways it can be opened
rs.open &quot;FORM_ID_198163500&quot;, conn, 2, 2


'Use the addnew method of the recordset object to add a record
rs.addnew
'Set the table column = to my input text box from my form
rs(&quot;DateofProc&quot;) = request(&quot;DateOfProc&quot;)
rs(&quot;ResidentName&quot;) = request(&quot;ResidentName&quot;)
rs(&quot;Rotation&quot;) = request(&quot;Rotation&quot;)
rs(&quot;PtFirstName&quot;) = request(&quot;PtFirstName&quot;)
rs(&quot;PtLastName&quot;) = request(&quot;PtLastName&quot;)
rs(&quot;DOB&quot;) = request(&quot;DOB&quot;)
rs(&quot;Sex&quot;) = request(&quot;Sex&quot;)
rs(&quot;MedRedNo&quot;) = request(&quot;MedRedNo&quot;)
rs(&quot;Continuity&quot;) = request(&quot;Continuity&quot;)
rs(&quot;Procedure1&quot;) = request(&quot;Procedure1&quot;)
rs(&quot;Involvement&quot;) = request(&quot;Involvement&quot;)
rs(&quot;TOPICCategory&quot;) = request(&quot;TOPICCategory&quot;)

'rs(&quot;DidYouFollowTheTOPICModel&quot;) = request(&quot;DidYouFollowTheTOPICModel&quot;)
rs(&quot;Supervisor&quot;) = request(&quot;Supervisor&quot;)
rs(&quot;OtherInfo&quot;) = request(&quot;OtherInfo&quot;)


rs(&quot;FacultyInCharge&quot;) = request(&quot;FacultyInCharge&quot;)
rs(&quot;ObservedBy&quot;) = request(&quot;ObservedBy&quot;)
rs(&quot;Comments&quot;) = request(&quot;Comments&quot;)
rs.update
'I do a movelast here to get the ID that is automatically generated
'I also set the value to a local variable so I can write out to the database
rs.movelast

%>

<html>
<head>
<title>sign on summary</title>
</head>
<body>
<TABLE BORDER=1>

Your Record # is:<% = strID %><br>
Your Name is <% = request(&quot;ResidentName&quot;) %><br>
Patient First Name is <% = request(&quot;PtFirstName&quot;) %><br>
Patient Last Name is <% = request(&quot;PtLastName&quot;) %><br>
continuity patient is <% = request(&quot;Continuity&quot;) %><br>

</body></html>
<%

'Always! Always set your objects to nothing. This clears them out of servers memory
'Your network admins will like this

set rs= nothing
set conn = nothing
%>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top