Wrox Programmer Forums
|
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 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 March 12th, 2006, 10:17 AM
Registered User
 
Join Date: Mar 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamic Checkboxes using dynamic Select Values

Hello,

I am trying to create an ASP page that has both dynamic checkboxes and dynamic Select lists which pulls its data from a database table. However, I also include a JavaScript function to disable the Select list by default and only enable the Select list if the Checkbox is clicked.

I am having the following problem: if i have 3 checkboxes with 3 select lists, when I click the first check box, it enables the first select list, which is what it's supposed to do. But when I click the second check box, it disables the first select list. So how can I get the second check box to enable the second select list, and so on?

Here is the code that i am trying to use:

Code:
<script language="Javascript">
<!--
function toggleStatus(cb, selID)
{    
    var sel = document.getElementById(selID);
    // This line disables the select when the checkbox is ON (ticked). 
    sel.disabled = !cb.checked;
}
//-->            
</script>
<% 
'Write the values
do while not rs.eof
%>
<form name="select_treatment" action="confirm_sale.asp" method="get" >
<td width="1000">
<input type="checkbox" name="<%=rs.Fields(0).Value%>" id="checkbox1" value="<%= rs("treatmentID")%>" onClick="toggleStatus(this,'select1' "></td>
<td width="1000" class="body"><%= rs("treatmentName") %></td>
<td width="1000" class="body"><%= rs("treatmentDescription") %></td>
<td width="1000" class="body">€<%= rs("treatmentPrice") %></td>
<td width="1000" class="body"><%= rs("treatmentDuration") %></td>
<td width="1000" class="body">

I think the Select Name and ID is where the problem occurs    
<select name="select1" id="select1" disabled>

<%
'while not the end of our staff member record set
do while not rs2.EOF 
%>
<option value="<%Response.Write rs2("staffID")%>"> <%Response.Write rs2("firstName")%></option>
<%
' Move to the next record
rs2.MoveNext
' Loop 
Loop

' move back to the first record
rs2.MoveFirst
%>
</td>
</tr>

<% 
rs.movenext
loop 
%>
</select>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic values stored in a select button using JSP dhruthi.ram99 Pro JSP 1 May 28th, 2007 07:33 AM
How to extract data from Dynamic Checkboxes? leothelion123 BOOK: Professional C#, 2nd and 3rd Editions 0 October 11th, 2006 04:35 AM
Dynamic select box from database values pk_jsp Javascript 1 May 4th, 2005 01:45 AM
multiple dynamic checkboxes mlog Classic ASP Basics 0 February 14th, 2004 04:49 AM
Dynamic form checkboxes Claralu Classic ASP Databases 2 August 5th, 2003 12:01 AM





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