deross
asked on
select box using java & vbscript
What is wrong with this code?
<%
dim tconn, tcstr, tsql, trs
set tconn = server.createobject("adodb .connectio n")
tconn.open("driver={micros oft access driver (*.mdb)}; dbq=d:\webspace\fw1\cc01\c com.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.opt ions[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.opt ions[x] = new option("<% =trs("TermID") %>","<% =trs("TermID") %>");
</script>
<%
trs.movenext
loop
trs.close
tconn.close
set trs = nothing
set tconn = nothing
%>
<%
dim tconn, tcstr, tsql, trs
set tconn = server.createobject("adodb
tconn.open("driver={micros
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.opt
</script>
<%
do while not trs.eof
%>
<script language="javascript" type="text/javascript">
x = x + 1
document.mform.tchoice.opt
</script>
<%
trs.movenext
loop
trs.close
tconn.close
set trs = nothing
set tconn = nothing
%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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.
ASKER
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.
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.
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!!!