[Javascript] How do you cycle thru the radio buttons on a webform ?
dev at qroute.net
dev at qroute.net
Tue Jun 1 16:11:18 CDT 2004
I got this script so far, but cannot read the length of the radio objects
for(var z = 0; z < window.document.frmSurvey.length; z++){
if ( window.document.frmSurvey[z].type == 'radio' )
{
var CurRadioChecked=false
//=========================================================================
//
// on the following line obj.length comes as undefined and I cannot run
the for X loop/
//
//=========================================================================
for(var x = 0; x < obj.length; x++){
if (window.document.obj[x].checked)
{
CurRadioChecked= true;
break;
}
}
if (CurRadioChecked)
{
//goto the next radio items this one is clear !...
}
else
{
alert('You must respond to all the required items. ' + obj.name + ' not
responded.')
break;
}
}
else
{
//alert('non radio')
}
}
----- Original Message -----
From: "Flavio Gomes" <flavio at economisa.com.br>
To: "[JavaScript List]" <javascript at LaTech.edu>
Sent: Tuesday, June 01, 2004 1:03 PM
Subject: Re: [Javascript] How do you cycle thru the radio buttons on a
webform ?
> document.formName is an array with all the form elements.
> document.formName.rbName is an array with all the radios from a radio
group;
>
> (They aren't arrays, they are objects, but you may cicle trought them
> with a for loop)
>
> ---
> Flavio Gomes
> flavio at economisa.com.br
>
>
> _/_/_/_/ _/ _/
> _/ _/ _/_/_/ _/ _/ _/_/
> _/_/_/ _/ _/ _/ _/ _/ _/ _/ _/
> _/ _/ _/ _/ _/ _/ _/ _/ _/
> _/ _/ _/_/_/ _/ _/ _/_/
>
>
>
> dev at qroute.net wrote:
>
> >I am running a survey.
> >I need to detect the radio optioned questions in it which are being
> >submitted with no option selected on them.
> >I know by default and by design principles, radio's gotto be presented
with
> >an option already pre-selected, but in my particular case, I want to send
> >the form with nothing pre-selected and force the user to select one.
> >
> >At submit time, I do not want to submit the form if a radio question is
left
> >blank.
> >How do you accomplish it ?
> >
> >
> >_______________________________________________
> >Javascript mailing list
> >Javascript at LaTech.edu
> >https://lists.LaTech.edu/mailman/listinfo/javascript
> >
> >
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
More information about the Javascript
mailing list