Dear All,
I'm building an Question/Answer Application in which I generate the Questions and Answers from Oracle database.
I'd like to validate through javascript that the user should answer each question.
First, I iterate through the questions.
Then, inside each question, I check if the user has chosen an answer (If the radio button is checked). If not alert a message.
I get the answer through:
but, when I iterate through it to check if it's checked or not:
I get this error:
Error: 'checked' is null or not an object
Here is the complete function:
------------------
--------------------------
I'm building an Question/Answer Application in which I generate the Questions and Answers from Oracle database.
I'd like to validate through javascript that the user should answer each question.
First, I iterate through the questions.
Then, inside each question, I check if the user has chosen an answer (If the radio button is checked). If not alert a message.
I get the answer through:
Code:
var ans_rdo = document.getElementsByName('answer'+i);
Code:
if(ans_rdo[j].checked == true)
Error: 'checked' is null or not an object
Here is the complete function:
------------------
Code:
function ValidateEntery() { var qst_cnt = Number(document.Form1.quest_count.value);//Number of Questions for(i=1; i <= qst_cnt; i++) { var chk_cnt = 0;//number of radio checked var ans_rdo = document.getElementsByName('answer'+i); //get the anser radio button for(j=1; j <= ans_rdo.length; j++) { [B][U]if(ans_rdo[j].checked == true)[/U][/B] // here I get this error: 'checked' is null or not an object { chk_cnt ++; } } if(chk_cnt <= 0) { alert("Please answer all questions"); return false; } } }
Comment