HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

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:
  #1  
Old June 15th, 2009, 05:52 AM
Samuha Samuha is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2009
Posts: 5 Samuha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 55 m 36 sec
Reputation Power: 0
Question JavaScript - Code which ensure only one checkbox is checked at any given time

Hi,

I have a series of questions and each question has 3 checkboxes for a user to choose from. How do i go about making sure that only 1 checkbox is ticked and not 2 or 3 for each question?

Before you go on and suggest that radio buttons are the way to go, i do know this but the company is called tickboxer and so a requirement is all selection boxes on the website need to be checkboxes. Does anyone have any JavaScript code that's compatible with ASP that will do the above?

Any help would be greatly appreciated.

Reply With Quote
  #2  
Old June 23rd, 2009, 03:42 AM
aashishnakra's Avatar
aashishnakra aashishnakra is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2009
Location: India
Posts: 316 aashishnakra User rank is Second Lieutenant (5000 - 10000 Reputation Level)aashishnakra User rank is Second Lieutenant (5000 - 10000 Reputation Level)aashishnakra User rank is Second Lieutenant (5000 - 10000 Reputation Level)aashishnakra User rank is Second Lieutenant (5000 - 10000 Reputation Level)aashishnakra User rank is Second Lieutenant (5000 - 10000 Reputation Level)aashishnakra User rank is Second Lieutenant (5000 - 10000 Reputation Level)aashishnakra User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 32 m 51 sec
Reputation Power: 75
Send a message via Yahoo to aashishnakra
Question

how about disabling the other check boxes when one is selected ?
__________________
“Life may not be the party we hoped for, but while we are here we should sing, dance and be merry all the time......."

Reply With Quote
  #3  
Old June 23rd, 2009, 04:59 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 3,416 sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 23 h 57 m 27 sec
Reputation Power: 1800
This script seems to do what you need:
Code:
<html>
<head>
<title>Checkbox Groups Act As Radio Buttons</title>
</head>
<body>
<form name='f1' action='#'>
 <p>
 <input type=checkbox name='cb1'>
 <input type=checkbox name='cb1'>
 <input type=checkbox name='cb1'>
 <input type=checkbox name='cb1'>
 <p>--------------
 <p>
 <input type=checkbox name='cb2'>
 <input type=checkbox name='cb2'>
 <input type=checkbox name='cb2'>
 <input type=checkbox name='cb2'>
</form>
<script type='text/javascript'>

function Cb2Rb( setRef )
{
 this.boxGroup = setRef;

 for( var i=0, len=setRef.length; i<len; i++ )
  setRef[ i ].onclick=( function(inst, idx){return function(){inst.scan(idx)}} )(this, i);

 this.scan=function(index)
 {
  if( this.boxGroup[ index ].checked )
   for(var i=0, g=this.boxGroup, len=g.length; i<len; i++)
    if( i != index )
     g[i].checked = false;
 }
  /*28432953637269707465726C61746976652E636F6D*/
}

new Cb2Rb( document.forms.f1.cb1 );
new Cb2Rb( document.forms.f1.cb2 );

</script>
</body>
</html>

full discussion

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingHTML, JavaScript And CSS Help > JavaScript - Code which ensure only one checkbox is checked at any given time


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!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

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





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
Stay green...Green IT