Disable radio learning after 10 seconds

I have a problem with turning off my radio objects.

I am generating some parameters from my mysql db with php as follows:

<input type=\"radio\" name=\"answer\" id=\"answer\" value=\"".$inhAnswer['id']."\"/> 

No problems:)

Then I use a countdown script, e.g. 10 seconds. This also works. Then after 10 seconds I want to turn off the radio buttons. I use this:

 document.form1.answer[0].disabled = true; 

It works. But what I need and I can’t understand is to disable ALL buttons. Now I can disable only the first. And I know that document.form1.answer [1] etc. Disconnect others, but I do not know how many radio beads will be used.

So, how can I let the script disable all response radio buttons at the same time?

Greetings

Toby

+4
source share
2 answers

but I don’t know how much radio will be used

Total number: document.form1.answer.length;

Docs: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/length

0
source

I'm not very sure, but you can try something like this.

 var children = document.form1.answer; for(var i=0; i<children.length; i++) { children[i].disabled = true; } 
0
source

Source: https://habr.com/ru/post/1383021/


All Articles