select box using java & vbscript

What is wrong with this code?

<%
dim tconn, tcstr, tsql, trs
set tconn = server.createobject("adodb.connection")
tconn.open("driver={microsoft access driver (*.mdb)}; dbq=d:\webspace\fw1\cc01\ccom.ca\db\ccom_atms.mdb")
tsql = "select TermID from TerminalID order by TermID"
set trs = tconn.execute(tsql)
%>
<script language="javascript" type="text/javascript">
var x = 0
document.mform.tchoice.options[x] = new option("Select A Terminal","2");
</script>
<%
do while not trs.eof
%>
<script language="javascript" type="text/javascript">
x = x + 1
document.mform.tchoice.options[x] = new option("<% =trs("TermID") %>","<% =trs("TermID") %>");
</script>
<%
trs.movenext
loop
trs.close
tconn.close
set trs = nothing
set tconn = nothing
%>
derossAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

amit_gCommented:
You probably are missing the select tag.

You could have simply done this ...

<%
dim tconn, tcstr, tsql, trs
set tconn = server.createobject("adodb.connection")
tconn.open("driver={microsoft access driver (*.mdb)}; dbq=d:\webspace\fw1\cc01\ccom.ca\db\ccom_atms.mdb")
tsql = "select TermID from TerminalID order by TermID"
set trs = tconn.execute(tsql)
%>
<select name="Whatever">
<option value="2">Select A Terminal</option>
<%
do while not trs.eof
%>
<option value="<% =trs("TermID") %>"><% =trs("TermID") %></option>
<%
trs.movenext
loop
trs.close
tconn.close
set trs = nothing
set tconn = nothing
%>
</select>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
findajayCommented:
Hey Friend,

If you want your code to work, simply put your code at the end of page. Or put it in a java script function and call in on OnLoad event of the body.

It is very important that the select box tag is defined before ur script tag.

Enjoy!!!
derossAuthor Commented:
I already have a select box.  This procedure is called when the user clicks one of two radio buttons (sort ascending or descening).  After the user clicks a radio button, the existing select box clears and re-populates.  If I put a select box tag, I get a brand new select box.
amit_gCommented:
You want to make the select in the client or server? The code you have shown is server side. Since you are already on the server there is no point in writing javascript code. If you wanted all this to happen without server call, then it needs to be totally in client side javascript.
derossAuthor Commented:
I think the whole thing needs a new approach.  All I want to do is:

Have a select box populated with records from an access database.

If the user clicks one of two radio buttons the select box should clear and be re-populated with the records from that same database but sorted by a different field.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.