473,394 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to separate an array of checkboxes into groups

How would I alert the user if they selected more than one COP1000 and in another instance alert the user if they selected more than one COP 2830. Right now it notifies the user if they selected more than one class.

Expand|Select|Wrap|Line Numbers
  1.  
  2. <script type="text/javascript" charset="utf-8">
  3. var p = 0;
  4. $(document).ready(function () {
  5.     $('input:checkbox').click(function () {
  6.         var COP1000 = $(this).attr('data');
  7.         if ($('input:checkbox:is_checked').attr()) {
  8.             p++;
  9.         }
  10.         if (p >= 2) {
  11.             alert('You can only select this class once');
  12.             return false;
  13.         }
  14.     });
  15. });
  16. </script>
  17.  
  18.  
  19.  
Below are checkboxes with data being the name of the class

Expand|Select|Wrap|Line Numbers
  1.  
  2. <input name="class[]" data="COP1000" value="<tr><td>COP1000 <td>8:00AM-9:00AM 
  3. </td><td>MWF </td><td>Sanford </td><td>3</td></tr>" type="checkbox" class="auto-
  4. style88"/>
  5. <input name="class[]" data="COP1000" value="<tr><td>COP1000 <td>11:30AM-12:00PM
  6. </td><td>TTH </td><td>Altamonte </td><td>3</td></tr>" type="checkbox" class="auto-
  7. style88" />
  8.  
  9. <input name="class[]" data="COP2830" value="<tr><td>COP2830 <td>11:00AM-12:00PM 
  10. </td><td>MWF </td><td>Sanford </td><td>3</td></tr>" type="checkbox" class="auto-
  11. style88"/>
  12. <input name="class[]" data="COP2830" value="<tr><td>COP2830 <td>6:00PM-8:45PM 
  13. </td><td>T </td><td>Altamonte </td><td>3</td></tr>" type="checkbox" class="auto-
  14. style88"/>
  15.  
  16.  
Mar 16 '12 #1
1 1395
Dormilich
8,658 Expert Mod 8TB
make it a radio button with a single name for each group that should be unique.

note: HTML code (i.e. the < and > of the HTML tags) are not allowed as attribute value.
Mar 16 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Mike S. Nowostawsky | last post by:
I tried using the "toUpperCase()" property to change the value of an array entity to uppercase BUT it tells me that the property is invalid. It seems that an array is not considered an object when...
41
by: puzzlecracker | last post by:
Given an array of size n and populated with consecutive integers from 1 to n i.e. in random order. Two integers are removed, meaning zero is placed in their places. Give O (n) efficient algorithm...
6
by: Yanhao Zhu | last post by:
Hi, all, If I have an array like int m = new int { 0, 1, 2, 3 }, is there a way I can separate the array into two, like int m01 = somefunction?(m,0,2) // m01 will hold 1st and 2nd items in...
1
by: kieran | last post by:
Hi, I have a string Array called Groups and this has x number of groups. Each row of the Array is divided up by ';' and has the name of the group in the second position (i.e. after the first...
7
by: Bint | last post by:
Hi, What is a simple way to shift the elements in an array, circularly? Is there a way to do it so that you don't need a separate storage array? IE I want to shift array A{1,2,3,4,5,6,7,8} by...
2
by: David TG | last post by:
Hiya! I would like to take a partial slice of a fairly complex array. The source looks something like array ( ==array ( ==NN
14
by: Lambda | last post by:
I'd like to create separate character pointers, pass them to a function to assign each one different value, and assign the pointers to an array. But when I try: #include <stdio.h> #include...
2
by: Kosmos | last post by:
I am opening the following connections as such although I am only referring to the first connection for this question: Dim con1 As ADODB.Connection Dim con2 As ADODB.Connection Dim recSet1 As...
16
by: =?iso-8859-1?Q?Daniel_Lidstr=F6m?= | last post by:
Hello! I have these following classes: public struct Move { public int From { get; set; } public int To { get; set; }
4
by: sarahaziz | last post by:
Hello guys i want to create something like this image ,consider the fact that Group and users comes from 2 different tables but only one query. I want to add them into one array....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.