Saturday, 23 August 2014

JavaScript- enable/ disable all radio buttons of a form

<HTML>
<Head>
<Script Language=JavaScript>

function Radios(isForm){

nElements = isForm.length;
for (i=0; i<nElements; i++)
{if (isForm[i].type == "radio"){isForm[i].disabled = true /false}}
}

</Script>
</Head>
<Body>
<Form name='Form1'>
<input type="radio" name="Product_1" value="1" id="q21">1
<input type="radio" name="Product_1" value="2" id="q21">2
<input type="radio" name="Product_1" value="3" id="q21">3<br>

<input type="radio" name="Product_2" value="1" id="q22">1
<input type="radio" name="Product_2" value="2" id="q22">2
<input type="radio" name="Product_2" value="3" id="q22">3<br>

<input type="radio" name="Product_3" value="1" id="q23">1
<input type="radio" name="Product_3" value="2" id="q23">2
<input type="radio" name="Product_3" value="3" id="q23">3<br>

<input type="radio" name="Product_4" value="1" id="q24">1
<input type="radio" name="Product_4" value="2" id="q24">2
<input type="radio" name="Product_4" value="3" id="q24">3<br>
<br>
<input type=button value="Disable All Radio" onclick="Radios(this.form)">
</Form>
</Body>
</HTML>

No comments:

Post a Comment