Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Databases
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 18th, 2004, 12:00 PM
Authorized User
 
Join Date: Sep 2003
Location: , , United Kingdom.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default Getting value of Dynamic Check boxes

Hi ya!

I hope someone can help me, i am creating an asp site and the problem is on one of my pages I have a dynamic table with info displayed and at the end of each row there is check box.

The value of the check box i have given the value of a field from the recoreset (The ID number),but now what i need to do is once one of the check boxes has been checked, i want to be able to get that ID number from the check box and pass it into the next page via the form..
I have tried several ways with no avail... its probably simple bt i have never cam across it before.....

Any help in the matter would be fab! Cheers ;)

Reply With Quote
  #2 (permalink)  
Old March 18th, 2004, 03:10 PM
Friend of Wrox
Points: 422, Level: 7
Points: 422, Level: 7 Points: 422, Level: 7 Points: 422, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: La Jolla, CA, USA.
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
Default

When you are rendering your page, fill in the value for each checkbox... as in the following example:

<form etc, etc...>
<input type="checkbox" name="your_checkbox_name" value="<%=rs.fields("ID")%>">
' ...
</form>

Now, I assume that you have more than one checkbox on your form...

When you post the form, Request("your_checkbox_name") will contain a comma delimited string of all of the values (IDs) that have been checked. If no checkboxes have been checked then Request("your_checkbox_name") will be an empty string.

You can parse the IDs using:

For Each ID_Value IN Split(Request("your_checkbox_name"),","))
  ' do something with each ID_Value here
  ' I like to use Trim(ID_Value) here to remove any leading or
  ' trailing space characters
Next

Hope that helps...

Reply With Quote
  #3 (permalink)  
Old March 19th, 2004, 03:35 AM
Authorized User
 
Join Date: Sep 2003
Location: , , United Kingdom.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, thanks fro your help so soon, I have tried the code you suggested this morning, however I am getting an error message of "object required"

Here's the code for th dynamic table (only 1 tick box will be chosen from however many is on the page (as its a dynamic number of check boxes depending on the number of records in the database))

<% if (not adoRS.BOF) and (not adoRS.EOF) then %>

<P align=center><STRONG>Select Relevant
Program</STRONG>:</P>
<P align=center><STRONG></STRONG></P>
<P>


<TABLE style="WIDTH: 532px; HEIGHT: 59px" border=1 align="center">

  <TR class=TableHeaderGrey>
    <TH width=50 align=middle><B>ID</B></TH>
    <TH width=450 align=middle ><B>Program Name</B></TH>
    <TH width=50 align=middle>Select</TH>
  </TR>


<%
    Do While Not (adoRS.EOF)
%>

    <TR class="<%=GetTableRowColor%>">
    <TD align=middle><%=adoRS.Fields(0).Value%></TD>

 <% gets data from database via VB DLL
  'get Program Description
  set objProject1 = Server.CreateObject("Project1.Class1")
  strProgramName = objProject1.GetProgramName(adoRS.Fields(0).Value)
  set objProject1 = nothing

  %>



    <TD align=middle><%=strProgramName%></TD>

Here are the dynamic check boxes:
    <TD align=middle><input id=chkProgram name="<%=adoRS.Fields(0).Value%>" type=checkbox onClick="DoCheckClick(this);"></TD>


</TR>
<%
 adoRS.MoveNext


loop

%>

</TABLE></P>



Maybe it applied your changes incorrectly... I thought i would have to implement some java script to pass the check box value into the form.....

Cheers very much for your help in advance! Kathryne

Reply With Quote
  #4 (permalink)  
Old March 19th, 2004, 05:44 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I don't know what sort of values the recordset contains but you might be better modifying ther name of the checkbox:
Code:
><input id=chkProgram name="chk<%=adoRS.Fields(0).Value%>" type=checkbox onClick="DoCheckClick(this);">
Is "object expected" a server side error or client side? If client side it's probably because DoCheckClick is not available.

--

Joe
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop over check boxes sams ASP.NET 1.0 and 1.1 Professional 5 July 17th, 2007 06:26 AM
Check Boxes Allan320 Access VBA 3 June 2nd, 2006 05:45 AM
Dynamic check boxes and select lists bsheridan Classic ASP Basics 1 March 17th, 2006 05:39 AM
Dynamic check boxes writing to database..help!! cincinnaticj7 Classic ASP Databases 0 January 25th, 2005 10:47 AM
Using check boxes in datagrid ractim ADO.NET 2 September 8th, 2004 08:28 AM



All times are GMT -4. The time now is 04:21 AM.


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