Inserting VBScript / JavaScript variables into ASP scripts ... again
by Andrew Browne <abrowne(at)pbm.co.za>
|
| Date: |
Fri, 21 Jan 2000 11:59:57 +0200 |
| To: |
"'hwg-languages(at)mail.hwg.org'" <hwg-languages(at)mail.hwg.org> |
| |
todo: View
Thread,
Original
|
|
Hi list
I am trying to design an ASP page where a list of doctors are displayed =
in a SELECT list on the left side of the page. When a list item is =
clicked, that doctors details must be displayed on the right side of the =
page. =20
I am using the GETROWS() method of the RECORDSET object to load the =
returned records into memory. Basically, the RECORDSET part of the ASP =
script looks like this:
Set RS =3D Server.CreateObject("ADODB.RecordSet")
RS.MaxRecords =3D 300
RS.CursorLocation =3D adUseClient
RS.open AdoCommand
DocList =3D RS.GetRows()=20
Later in my page I use this array to populate an HTML SELECT object with =
a list of doctor names:
<% if RS.RecordCount > 0 then %>=20
<% RS.MoveFirst %>
<% FOR i =3D 0 TO RS.RecordCount -1 %>=20
<OPTION VALUE=3D"<% =3D i %> "><% =3D DocList(1,i) %>=20
<% NEXT %>
<% else %>=20
<option value=3D"nothing">No doctors for this selection
<% end if %>=20
=20
I then have a VBScript sub that executes when the user clicks on one of =
the options in the list:
<script language=3D"VBScript">
SUB DoctorSelect_OnChange()
doctor =3D document.MaintenanceDoctor.DoctorSelect.value
=20
document.MaintenanceDoctor.RegNumber.value =3D "<%=3D DocList(0,doctor) =
%>"
document.MaintenanceDoctor.DocType.value =3D"<%=3D DocList(2,doctor) =
%>"
document.MaintenanceDoctor.ContactDate.value =3D" <%=3D =
DocList(3,doctor) %>"
document.MaintenanceDoctor.PayDate.value =3D "<%=3D DocList(5,doctor) =
%>"
=09
END SUB
</script>
The ASP works fine - the right records are returned and the DocList =
array is also correct. The DoctorSelect sub executes and populates the =
doctor details fields without any errors. The problem is that no matter =
which doctor I click on, the details of the first doctor in the DocList =
array are always displayed. I suspect that "<%=3D DocList(0,doctor) =
%>" is not being updated with the value "doctor =3D =
document.MaintenanceDoctor.DoctorSelect.value". I initially attempted =
this in JavaScript. When errors occurred, I rewrote it in VBScript =
because all our ASP is writen in VBScript. But still it would appear =
that I cannot use a VB variable in an ASP script. I can't break the ASP =
script, concatenate the doctor variable and then add the rest of the =
script in the following manner:
"<%=3D DocList(0," & doctor & ") %>"
I've even tried the following (with no joy - it just returned the =
string, not the asp array item):
a1 =3D "<"
a2 =3D "%=3D"
a3 =3D " DocList(0,"
a4 =3D " %"
a5 =3D ">"
document.MaintenanceDoctor.RegNumber.value =3D a1 + a2 + a3 + doctor + =
a4 +a5
Any ideas or suggestion? I am considering replacing the select list =
with a normal url list, each with a series of hidden fields. But it =
would save a lot of code if I could get the above code to work =
correctly.
Thanks in advance for your thoughst on the subject
Andrew
HWG: hwg-languages mailing list archives,
maintained by Webmasters @ IWA
This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.