Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To 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
  #1 (permalink)  
Old September 18th, 2006, 02:24 AM
Registered User
Points: 1,897, Level: 17
Points: 1,897, Level: 17 Points: 1,897, Level: 17 Points: 1,897, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: Mumbai, Maharastra, India.
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default Validating group of radio buttons.

i m having around 15 group of radio buttons on my page and they all are mendatory.

i have use similar coding as below site has given:
http://www.codeave.com/javascript/code.asp?u_log=7049

but since this is an online q'naire, and this code works for a single group of radio buttons, what i want is that there should be common radio button checknig function to which we can pass a name of radio button group,
i tried to modify the code a bit but it is not working....any idea?

Rupen Anjaria.:)
------------------
We CAN'T avoid problems, but can solve it.
  #2 (permalink)  
Old September 18th, 2006, 02: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

As you can't uncheck a radio button without checking a different one then if you make one checked to begin with then it should mean the groups are all mandatory.

If you want to check with code:
Code:
function getCheckedControl(groupName)
{
  var col = document.getElementsByName(groupName);
  for (var i = 0; i < col.length; i++)
  {
    if (col[i].checked) return col[i];
  }
  return null;
}
If the code above returns null when passed the group name then no option is chosen.

--

Joe (Microsoft MVP - XML)


Similar Threads
Thread Thread Starter Forum Replies Last Post
InfoPath radio buttons MichaelBjerke Infopath 0 May 29th, 2007 10:27 AM
Group name for radio buttons in Grid view nitinp ASP.NET 2.0 Professional 0 February 27th, 2007 07:15 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





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