![]() |
| ||
| ASP electronic exam project, problem when update data base hellow i have problem with my exam project i program it in asp , and i have javascript function and this function should return the value of raduo button checked and i then use this value in ASP code the problem is that function return null or undifined i try to send the file exam.asp but i can't so i paste the code here please coppy it and try to see where the error <!--#include file="Connection.asp"--> <html dir="rtl"> <head> <script language = "JavaScript"> function getRadioValue(radioObject) { for (var i=0; i<radioObject.length; i++) { if (radioObject[i].checked) { var answer = radioObject[i].value; break ; } } return answer } </script> <title> Electronic Computer Network Exam </title> </head> <body > <p align="center"><i><b><font color="#432896" size="6" face="Comic Sans MS">Computer Network Exam </font></b></i></p> <table dir= rtl border="0" width="100%" id="table1"> <% if request("do")="next" then i=request("i") i=i+1 elseif request("do")="pervious" then i=request("i") i=i-1 else i=2 end if selectSQL="select * from question " Dim oRecordset Set rs = Server.CreateObject("ADODB.Recordset") rs.CursorLocation = 3 'adUseClientrs.CursorLocation = 3 ' adUseClient rs.pagesize=1 rs.open selectSQL,ado if cint(i)>rs.pagecount+1 then 'update_Answer() response.write "end of questions.............." & rs.pagecount &"?" response.redirect("result.asp") end if rs.AbsolutePage=i-1 if cint(i)<2 then response.redirect ("exam2.asp") end if if NOT rs.EOF then %> <tr> <td align="left" height="19"><p> <font color="#800000" face="Times New Roman"><%=rs.FIELDS("Question").VALUE%> </font> </td> <td width="67" height="19"><font color="#800000"><b> <font face="Times New Roman"><%=rs.FIELDS("Q_ID").VALUE%></font> <INPUT type=hidden value=<%=rs.FIELDS("Q_ID").VALUE%> name="m"></b> </font> <font face="Times New Roman"> <b><font color="#800000"> Q</font></b></font></td> </tr> <form method="get" name="answer_form"> <tr> <td align="left"><font face="Times New Roman"><%=rs.FIELDS("a").VALUE%></font></td> <td width="67"><font color="#000080" face="Times New Roman"> <INPUT type="radio" value="1" name="R1" style="font-weight: 700"><b>a</b></font> </td> </tr> <tr> <td align="left"><font face="Times New Roman"><%=rs.FIELDS("b").VALUE%></font></td> <td width="67"><font color="#000080" face="Times New Roman"> <INPUT type="radio" value="2" name="R1" style="font-weight: 700"><b>b</b></font></td> </tr> <tr> <td align="left"><font face="Times New Roman"><%=rs.FIELDS("c").VALUE%></font></td> <td width="67"><font color="#000080" face="Times New Roman"> <INPUT type="radio" value="3" name="R1" style="font-weight: 700"><b>c</b></font></td> </tr> <tr> <td align="left"><font face="Times New Roman"><%=rs.FIELDS("d").VALUE%></font></td> <td width="67"><font color="#000080" face="Times New Roman"> <INPUT type="radio" value="4" name="R1" style="font-weight: 700"><b>d</b></font></td> </tr> </form > <script LANGUAGE="JavaScript"><!--BEGIN HIDING radio=getRadioValue(answer_form.R1) alert(getRadioValue(answer_form.R1)) //END HIDING--> </SCRIPT> <form> <tr> <td> <p align="left"> <input type="checkbox" name="MyCheck<%=i%>" value="<%=rs.FIELDS("Q_ID").VALUE%>" style="float: left">mark</p> </td> </tr> <input type="hidden" name="counter" value="<%=i%>"> <% update_Answer() %> </form> <% if request("do")="review" then response.redirect("review.asp") end if %> <% if request("do")="end" then response.redirect ("result.asp") end if %> <% end if %> </table> <TABLE id=table2 style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-COLLAPSE: collapse; BORDER-RIGHT-WIDTH: 0px" borderColor=#111111 height=1 cellSpacing=0 cellPadding=0 width=749 align=left border=1> <TBODY> <TR> <TD style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none" align=middle width=97 height=1> <FORM method=POST action="?do=next" > <INPUT type=hidden value=<%=i%> name="i"> <P align=center> <INPUT style="FONT-SIZE: 14pt; FLOAT: right" type=submit value=" NEXT" name=NEXT ></P> </FORM> </TD> <TD style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none" align=middle width=154 height=1> <form method="POST" action="?do=pervious"> <INPUT type=hidden value=<%=i%> name="i"> <INPUT style="FONT-SIZE: 14pt; FLOAT: right" type=submit value=PERVIOUS name=PERVIOUS> </form> </TD> <TD style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none" align=middle width=103 height=1> <form method="POST" action="?do=review"> <input type="submit" value="Review" name="Review" style="font-size: 14pt; float:right"> </form> </TD> <TD style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none" align=middle width=219 height=1> <FORM method=POST action="?do=end"><P> <INPUT style="FONT-SIZE: 14pt; FLOAT: left" type=submit value="END " name="END "></P> </FORM> </TD> </TR> </TBODY> <% update_Answer()%> </TABLE> <% Sub update_Answer() r=request("radio") 'Initialise the strSQL variable with an SQL statement to query the database strSQL = "SELECT answer.* FROM answer WHERE Q_ID="&(rs.FIELDS("Q_ID").VALUE-1) 'Reset server objects rs.Close Set rs = Nothing Set rs = Server.CreateObject("ADODB.Recordset") 'Set the cursor type we are using so we can navigate through the recordset rs.CursorType = 2 'Set the lock type so that the record is locked by ADO when it is updated rs.LockType = 3 'Open the recordset with the SQL query rs.Open strSQL, ado 'Update the record in the recordset rs.Fields("user_answer")=cint® 'Write the updated recordset to the database rs.Update 'Reset server objects rs.Close Set rs = Nothing Set adoCon = Nothing End Sub %> </body> </html> please help me if you can thanks |
| All times are GMT -4. The time now is 12:17 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC