Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 3rd, 2005, 04:14 PM
Registered User
 
Join Date: Sep 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Data Bound Radio Buttons

hi guys,

I am doing a class register on a website where i will generate a list of names of students from a database and alongside each name there will be three radio buttons labelled "Present", "Absent" and "Late".

Generating the list of names to come on the website is very easy, the problem is how do i connect the three radio buttons to the names so when for example the "present" radio button is checked for that student, it will register on the database that he is present on a specific date.

I can do it with fixed values, for example if there are fixed names of pupils i can always name the radio buttons and it's easy from there but the names are generated at random from a long list in the database.
----------------------------------------------------------------------------------------------------------------------

I've got 2 pages. one with the form on it and the second to do the "insert" into the database.

Here is the code for the 2 pages.

------------------------------------------------
page1.asp
------------------------------------------------

<table width="395" height="38" border="2" cellpadding="2" cellspacing="0" bordercolor="#111111" style="border-collapse: collapse">
      <%
sql = "Select * from tblstudent order by StudentID";
rs=myconn.Execute(sql);
while (!rs.eof)
{
    %><tr>
        <td width="200" height="34"><div align="center"><span class="style2"><%=rs("StudentID")%></span></div>
        <td width="200" class="style1"><span class="style2"><%=rs("Name")%></span>
        <td width="200" class="style1"><div align="center"><span class="style2">
            <input name="rbtnPresent" type="radio" value="<%=rs("StudentID")%>">
          </span></div>
        <td width="200" class="style1"><div align="center"><span class="style2">
            <input name="rbtnAbsent" type="radio" value="<%=rs("StudentID")%>">
          </span></div>
        <td width="200" class="style1"><div align="center"><span class="style2">
            <input name="rbtnLate" type="radio" value="<%=rs("StudentID")%>">
          </span></div>
          <%
    rs.movenext();
}
rs.Close();
%>
      </table>



------------------------------------------------
page2.asp
------------------------------------------------

<%
var StudentID = Request.form("StudentID");
var Present = Request.form("rbtnPresent");
var Absent = Request.form("rbtnAbsent");
var Late = Request.form("rbtnLate");
%>

<table width="395" height="140" border="2" cellpadding="2" cellspacing="0" bordercolor="#111111" style="border-collapse: collapse">
      <%
sql = "insert into tblattend (StudentID, Present, Absent, Late) ";
sql = sql + " values ('" + StudentID + "', " + Present + ", " + Absent + ", " + Late + ");" ;
rs=myconn.Execute(sql);
    %>
Record added! :)

    </table>

----------------------------------------------------------------------------------------------------------------------

I have all the connections to the database correct, nothing wrong on that side, just the radio buttons part. you have the code anyway, try it out with a database with 5 names just to test it.

This is last resort, i hope you can help

Thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
Radio Buttons and Calculations Student101 Java Basics 4 June 21st, 2009 11:02 AM
Radio buttons disappear JoeBob49 ASP.NET 2.0 Basics 2 November 27th, 2006 09:57 AM
How to use the radio buttons? ben_VB VB.NET 2002/2003 Basics 1 January 18th, 2005 12:29 PM
Radio buttons over email??? morpheus Classic ASP Basics 5 April 20th, 2004 01:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.