[Javascript] Noob - JS/XHTML 1.1/Forms

Shawn Milo shawn.milo at gmail.com
Fri Mar 25 15:51:08 CST 2005


Do something like this:

var x = 0;
var radioCount = 0;
for (x=0; x < document.elements.count; x++){

   if (document.elements[x].type = 'radio'){

      radioCount += 1;
  }


}


This is untested, and I'm sure that there are flaws in the syntax. But
try it out, and check Google Groups to fill in the gaps. I'm not
taking the time to make this work partially because I'm doing other
things, and partially because if you are relatively new, it will be a
learning experience for you.

Shawn



On Sat, 26 Mar 2005 08:37:26 +1100, Abyss <info at abyss.ws> wrote:
>  
> Hi All, Im new to this mailing list...please try to be gentle :) 
>   
> 
> I have a heap of radio buttons that are generated from a database(which will
> change at random), and i will never know the exact number of radio buttons
> that have been printed. 
>   
> Do you know if there is any way to return a radio button amount? like a
> total amount that are printed out? via javascript? 
>   
> If so do you have any example code? or any links to any tutorials? 
>   
> Also does anyone have any code that will help me validate the radio buttons?
>   
> im looking to display a "no buttons" message if no radio buttons are put
> into the form 
>   
> and if there are radio buttons put into the form if none are selected then
> display a error message about how they must select one of the radio buttons.
>   
> this all on the submit button pressing.... 
>   
> while im writing this out.. 
>   
> I am not sure  but are you allowed to put javascript code out of the head
> document in a xhtml 1.1 page? 
>   
> like just before the end html tags? 
>   
>   
>   
>   
> Thanks heaps
> Abyss
> Australia
>  
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> 
> 
> 


-- 
Voicemail any time at:
206-666-MILO



More information about the Javascript mailing list