ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old February 16th, 2008, 04:31 AM
izzzz izzzz is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 1 izzzz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 18 sec
Reputation Power: 0
Exclamation Asp -retrieved selected radio value

hi am trying to code a online exam in asp .i need to retrive the value of radio selected by user for mark calculation...plz help me with it.. thanks in advance.. the table has qn,4choices n ans..
Code:
<% Option Explicit 
Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Const adCmdTableDirect = &H0200
Const adUseClient = 3
Dim adoCon
Dim rs
Dim strSQL
%>
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<form name="conduc" method="post">
<%
	
	Set adoCon = Server.CreateObject("ADODB.Connection")  	
	Set rs= Server.CreateObject("ADODB.Recordset")
	adoCon.Open "DSN=online_details"
	strSQL="SELECT * FROM level1" 
		if Len(Request("pagenum")) > 0  then
			response.write "choice" & Request("choice")
The mark calculation should appear here
		end if
		
		rs.PageSize = 1
		rs.CacheSize = 1
		rs.CursorLocation = adUseClient
   		rs.open strSQL,adoCon
		If Len(Request("pagenum")) = 0  Then
				rs.AbsolutePage = 1
			Else
				If CInt(Request("pagenum")) <= rs.PageCount Then
						rs.AbsolutePage = Request("pagenum")
					Else
						rs.AbsolutePage = 1
				End If
		End If
		
		Dim abspage, pagecnt
			abspage = rs.AbsolutePage
			pagecnt = rs.PageCount
		
		If Not rs.EOF Then
				
				response.write rs.Fields("Question")
				response.write "<br><input type=radio name=choice value=first>" 
				response.write rs.Fields("Option1")
				response.write "<br><input type=radio name=choice value=second>" 
				response.write rs.Fields("Option2")
				response.write "<br><input type=radio name=choice value=third>" 
				response.write rs.Fields("Option3")
				response.write "<br><input type=radio name=choice value=fourth>" 
				response.write rs.Fields("Option4")
 				Response.Write "</form>"
				response.write("Select your option,click next to confirm and go to next question")
				response.write  "" & Request.ServerVariables("SCRIPT_NAME") & "?pagenum=" & abspage + 1 & ""
				If abspage < pagecnt Then
				Response.Write "<a href=""" & Request.ServerVariables("SCRIPT_NAME") & "?pagenum=" & abspage + 1 &  &""">Next </a>"
				
				End If
		End If						
		rs.Close
		Set rs = Nothing
%>
</body>
</html>

Reply With Quote
  #2  
Old February 16th, 2008, 04:02 PM
keep_it_simple's Avatar
keep_it_simple keep_it_simple is offline
KIS
ASP Free Novice (500 - 999 posts)
 
Join Date: Jul 2007
Location: USA
Posts: 969 keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 3 h 4 m 57 sec
Reputation Power: 280
Send a message via Yahoo to keep_it_simple
Quote:
Originally Posted by izzzz
hi am trying to code a online exam in asp .i need to retrive the value of radio selected by user for mark calculation...plz help me with it.. thanks in advance.. the table has qn,4choices n ans..
Code:
<% Option Explicit 
Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Const adCmdTableDirect = &H0200
Const adUseClient = 3
Dim adoCon
Dim rs
Dim strSQL
%>
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<form name="conduc" method="post">
<%
	
	Set adoCon = Server.CreateObject("ADODB.Connection")  	
	Set rs= Server.CreateObject("ADODB.Recordset")
	adoCon.Open "DSN=online_details"
	strSQL="SELECT * FROM level1" 
		if Len(Request("pagenum")) > 0  then
			response.write "choice" & Request("choice")
The mark calculation should appear here
		end if
		
		rs.PageSize = 1
		rs.CacheSize = 1
		rs.CursorLocation = adUseClient
   		rs.open strSQL,adoCon
		If Len(Request("pagenum")) = 0  Then
				rs.AbsolutePage = 1
			Else
				If CInt(Request("pagenum")) <= rs.PageCount Then
						rs.AbsolutePage = Request("pagenum")
					Else
						rs.AbsolutePage = 1
				End If
		End If
		
		Dim abspage, pagecnt
			abspage = rs.AbsolutePage
			pagecnt = rs.PageCount
		
		If Not rs.EOF Then
				
				response.write rs.Fields("Question")
				response.write "<br><input type=radio name=choice value=first>" 
				response.write rs.Fields("Option1")
				response.write "<br><input type=radio name=choice value=second>" 
				response.write rs.Fields("Option2")
				response.write "<br><input type=radio name=choice value=third>" 
				response.write rs.Fields("Option3")
				response.write "<br><input type=radio name=choice value=fourth>" 
				response.write rs.Fields("Option4")
 				Response.Write "</form>"
				response.write("Select your option,click next to confirm and go to next question")
				response.write  "" & Request.ServerVariables("SCRIPT_NAME") & "?pagenum=" & abspage + 1 & ""
				If abspage < pagecnt Then
				Response.Write "<a href=""" & Request.ServerVariables("SCRIPT_NAME") & "?pagenum=" & abspage + 1 &  &""">Next </a>"
				
				End If
		End If						
		rs.Close
		Set rs = Nothing
%>
</body>
</html>



instead of trying to explain the request objects (form(post)/querystring(get) i modified your code with a request.form method vs a link (get)....in a nutshell the link carries the value of pagenum fine...however it does not "post" values from the form like a submit button...either use javascript or a submit button...you can use an input type=image if you do not care for the basic submit button...this tag is a natural submit button despite its name...


also note i used a dsn-less connection and a for loop vs writing out the same pattern ...also...at the end your logic removes the next button...however you'll have figure out the logic for final submission....let us know if you have trouble when you get to that point...the shell is there...modify as needed...good luck
Code:
<% 'Option Explicit %>

<html>
 <head>
  <title>Untitled Document</title>
 </head>
 <body>
  <form name="conduc" method="post" action="<%=Request.ServerVariables("SCRIPT_NAME")%>">

<%
   Const adOpenForwardOnly = 0
   Const adLockReadOnly = 1
   Const adCmdTableDirect = &H0200
   Const adUseClient = 3

   Dim adoCon, rs, strSQL,abspage, pagecnt,sFilePath,sConn,iPageNum, sChoice

   iPageNum = Request.Form("pagenum")
   strSQL="SELECT * FROM level1"

   Response.Write "<p>" & Request.Form("choice") & "</p>"

   Set adoCon = Server.CreateObject("ADODB.Connection")
   Set rs = Server.CreateObject("ADODB.recordset")
   sProvider = "Provider=Microsoft.Jet.OLEDB.4.0;"
   sPath = "Data Source=" & Server.MapPath("db/online_details.mdb") & ";"
   adoCon.Open sProvider & sPath

   rs.PageSize = 1
   rs.CacheSize = 1
   rs.CursorLocation = adUseClient
   rs.open strSQL,adoCon
	
   If Len(iPageNum) = 0 Then
    rs.AbsolutePage = 1
   Else
    If CInt(iPageNum) <= rs.PageCount Then
     rs.AbsolutePage = iPageNum
    Else
     rs.AbsolutePage = 1
    End If
   End If
		
   abspage = rs.AbsolutePage
   pagecnt = rs.PageCount
		
   If Not rs.EOF Then

    Response.Write rs("Question") & "<br>"
    
    For i = 1 to 4
     Response.Write _
    
     "<input type=""radio"" name=""choice"" value=""Option_" & i & """>" & rs("Option" & i) & "<br>" & vbcrlf
    Next	

   End If
			
   Response.Write "<p>Select your option, click next to confirm and go to next question</p>"
  
 	
   If abspage < pagecnt Then
    Response.Write "<input type=""hidden"" name=""pagenum"" value=""" & abspage + 1 & """>" & vbcrlf & _
                   "<input type=""image"" src=""http://persianmirror.com/Images/PhotoAlbumButtons/next.jpg"">"
   End If
  						

  rs.Close
  Set rs = Nothing
 
%>

   
 </form>
</body>
</html>

Last edited by keep_it_simple : February 16th, 2008 at 04:08 PM.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingASP Development > Asp -retrieved selected radio value


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway