I use this function for the exact same purpose.
It checks radio buttons named "ShippingID1",
"ShippingID2", etc. Just replace the string
"ShippingID" with the name of the radio buttons.
Mark
function ValidateShipOption(){
var StringToSearchFor = new String("ShippingID");
var SearchStringLength = StringToSearchFor.length;
var currControl, currControlName, strValue;
var NumControls
document.frmOrderDetails.elements.length;
var strNoQTYFound = true;
for (go = 0; go < NumControls; go++){
currControl = document.frmOrderDetails.elements[go];
currControlName = new String(currControl.name);
//Check the control to see if it's an address radio
button.
if (currControlName.substring(0, SearchStringLength)
== "ShippingID"){
//It is, let's grab the value of the radio button.
strValue = currControl.checked;
//Now evaluate the value of the radion button.
if(strValue==true){
//Radio button is selected, set flag.
strNoQTYFound=false;
}
}
//Before we proceed to the next control, evaluate
the current one.
//If it's true, we don't need to go any further.
Break.
if(strNoQTYFound==false){
break;
}
}
//Return value of search.
return strNoQTYFound;
//alert("value of strNoQTYFound = " + strNoQTYFound);
}
--- delcyan@w... wrote:
> Hello all,
>
> I have a group of radio buttons on a form. When I
> submit, I want to
> verify whether a selection was made on each line
> (group of radio button).
>
> The name of all radio button is "hd1", "hd2", etc. I
> have removed the
> number at the end of the name so I can use a
> counter. Plus, I need a
> counter to loop through the group.
>
> This is not seems to be easy in javScript. Can
> someone help me. See the
> following function.
>
> Thank you
>
> function checkRequired(f){
> //Verify whether the user has made a selection
> var intCount =0
> var intTest = 0
> var intControlGrp = 1
> var strDummy = ""
>
> while(intControlGrp <=5)
> {
> for(intCount=0;intCount<=3;intCount++)
> {
> strDummy = intControlGrp.toString()
> if (f.hd + strDummy + (intCount).checked == true)
> {
> intTest = 2;
> }//Closing If
> }//Closing For
> intControlGrp++
> }//Closing While
>
> f.submit();return true;
> }
>
> ---
>
> Improve your web design skills with these new books
> from Glasshaus.
>
> Usable Web Menus
>
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
> r-20
> Constructing Accessible Web Sites
>
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
> r-20
> Practical JavaScript for the Usable Web
>
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
> r-20
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com