<%
dim connect, rs, sql, scolor, i, isans
set connect = server.createobject("ADODB.Connection")
connect.open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &_
Server.MapPath("\perlphpasp\db\quiz.mdb"))
sql = "select * from math01"
set rs = connect.execute(sql)
response.write("<body>")
i = 1
do while not rs.eof
response.write("<hr>" & i & " : " & rs("question"))
if (rs("ans") = 1) then isans = "1" else isans = "0" end if
response.write("<br><input type=radio onclick=chk("&isans&")>a. "&rs("choice1"))
if (rs("ans") = 2) then isans = "1" else isans = "0" end if
response.write("<br><input type=radio onclick=chk("&isans&")>b. "&rs("choice2"))
if (rs("ans") = 3) then isans = "1" else isans = "0" end if
response.write("<br><input type=radio onclick=chk("&isans&")>c. "&rs("choice3"))
if (rs("ans") = 4) then isans = "1" else isans = "0" end if
response.write("<br><input type=radio onclick=chk("&isans&")>d. "&rs("choice4"))
rs.movenext
i = i + 1
loop
response.write("</body>")
connect.close
set rs = nothing
set connect = nothing
%>
<script language="JavaScript">
<!--
function chk(value) {
if( value == 0) {
alert('Wrong') } else {
alert('Right');
}
return true;
}
// -->
</script>
จำนวน : 38 บรรทัด