469,625 Members | 1,659 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

Error: document.forms[0].sec11_A has no properties

5
I'm having issues, I've spent many hours searching and I'm a noob at javascript, any help will be greatly appreciated.

I keep getting the following error:
Error: document.forms[0].sec11_A has no properties

with this script:

Expand|Select|Wrap|Line Numbers
  1. function checkform(btntype)
  2. {
  3.     var haserrors=0;
  4.     document.getElementById('e_sec11_1').style.color = "black";
  5.     document.getElementById('e_sec11_2').style.color = "black";
  6.     document.getElementById('e_sec11_3').style.color = "black";
  7.     document.getElementById('e_sec11_4').style.color = "black";
  8.     document.getElementById('e_sec11_5').style.color = "black";
  9.     document.getElementById('e_sec11_6').style.color = "black";
  10.     document.getElementById('e_sec11_7').style.color = "black";
  11.     document.getElementById('e_sec11_8').style.color = "black";
  12.     document.getElementById('e_sec11_9').style.color = "black";
  13.  
  14.     //Sec11_A
  15.     var sec11_Achecked=0;
  16.     for (i=0;i<document.forms[0].sec11_A.length;i++) {
  17.         if (document.forms[0].sec11_A[i].checked) {
  18.         sec11_Achecked=1;
  19.         }
  20.     }
  21.     if (sec11_Achecked<1) {
  22.         haserrors=1;
  23.         document.getElementById('e_sec11_1').style.color = "red";
  24.     }
  25.  
  26.     //Sec11_B
  27.     var sec11_Bchecked=0;
  28.     for (i=0;i<document.forms[0].sec11_B.length;i++) {
  29.         if (document.forms[0].sec11_B[i].checked) {
  30.         sec11_Bchecked=1;
  31.         }
  32.     }
  33.     if (sec11_Bchecked<1) {
  34.         haserrors=1;
  35.         document.getElementById('e_sec11_2').style.color = "red";
  36.     }
  37.  
  38.     //Sec11_C
  39.     var sec11_Cchecked=0;
  40.     for (i=0;i<document.forms[0].sec11_C.length;i++) {
  41.         if (document.forms[0].sec11_C[i].checked) {
  42.         sec11_Cchecked=1;
  43.         }
  44.     }
  45.     if (sec11_Cchecked<1) {
  46.         haserrors=1;
  47.         document.getElementById('e_sec11_3').style.color = "red";
  48.     }
  49.  
  50.     //Sec11_D
  51.     var sec11_Dchecked=0;
  52.     for (i=0;i<document.forms[0].sec11_D.length;i++) {
  53.         if (document.forms[0].sec11_D[i].checked) {
  54.         sec11_Dchecked=1;
  55.         }
  56.     }
  57.     if (sec11_Dchecked<1) {
  58.         haserrors=1;
  59.         document.getElementById('e_sec11_4').style.color = "red";
  60.     }
  61.  
  62.     //Sec11_E
  63.     var sec11_Echecked=0;
  64.     for (i=0;i<document.forms[0].sec11_E.length;i++) {
  65.         if (document.forms[0].sec11_E[i].checked) {
  66.         sec11_Echecked=1;
  67.         }
  68.     }
  69.     if (sec11_Echecked<1) {
  70.         haserrors=1;
  71.         document.getElementById('e_sec11_5').style.color = "red";
  72.     }
  73.     if (LEN(ALLTRIM(document.myform.sec11_6.value)) == 0) {
  74.         haserrors=1;
  75.         document.getElementById('e_sec11_6').style.color = "red";
  76.     }
  77.     if (LEN(ALLTRIM(document.myform.sec11_7.value)) == 0) {
  78.         haserrors=1;
  79.         document.getElementById('e_sec11_7').style.color = "red";
  80.     }
  81.     if (LEN(ALLTRIM(document.myform.sec11_8.value)) == 0) {
  82.         haserrors=1;
  83.         document.getElementById('e_sec11_8').style.color = "red";
  84.     }
  85.     if (LEN(ALLTRIM(document.myform.sec11_9.value)) == 0) {
  86.         haserrors=1;
  87.         document.getElementById('e_sec11_9').style.color = "red";
  88.     }
  89.  
  90.     if (btntype=="next" ) {
  91.         document.myform.btntype.value="next";
  92.     } else {
  93.         if (btntype=="back") {
  94.             document.myform.btntype.value="back";
  95.         }
  96.     }
  97.  
  98.     if (haserrors>0) {
  99.  
  100.             var answer=confirm("Are you sure you want to continue without completing the evalutation?");
  101.             if (answer) {
  102.                 document.myform.submit();
  103.             } else {
  104.                 return;
  105.             }
  106.  
  107. }
  108.  
Thanks in advance.

Lee
Jun 18 '07 #1
6 3177
epots9
1,351 Expert 1GB
if your HTML what is "sec11_A"? Which element has that as its id? and what type of element is it?
Jun 18 '07 #2
therig
5
It's for a radio button:

Expand|Select|Wrap|Line Numbers
  1. <input style="border:0px; width:15px; height:15px;" name="sec11_A" id="sec11_A" type="radio" value="1" <%=sec11_A1%> />
Jun 18 '07 #3
epots9
1,351 Expert 1GB
how many radio buttons are in the group sec11_A? if there is only one, then maybe u should change it to a checkbox, maybe that would do the trick.
Jun 18 '07 #4
therig
5
There's actually 3 in that group:
Expand|Select|Wrap|Line Numbers
  1.  <input style="border:0px; width:15px; height:15px;" name="sec11_A" id="sec11_A" type="radio" value="1" <%=sec11_A1%> />
  2.  
  3.  <input style="border:0px; width:15px; height:15px;" name="sec11_A" id="sec11_A" type="radio" value="2" <%=sec11_A2%> />
  4.  
  5.  <input style="border:0px; width:15px; height:15px;" name="sec11_A" id="sec11_A" type="radio" value="3" <%=sec11_A3%> />
  6.  
Jun 18 '07 #5
epots9
1,351 Expert 1GB
try this:
Expand|Select|Wrap|Line Numbers
  1. for (i=0;i<document.formName.sec11_A.length;i++)
  2.  
replace formName with the name of your form. u might have to change the others too.

good luck
Jun 18 '07 #6
therig
5
try this:
Expand|Select|Wrap|Line Numbers
  1. for (i=0;i<document.formName.sec11_A.length;i++)
  2.  
replace formName with the name of your form. u might have to change the others too.

good luck
Perfect.

Thanks,
Lee
Jun 18 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Wow | last post: by
3 posts views Thread by Frances Del Rio | last post: by
7 posts views Thread by debugger | last post: by
reply views Thread by Kenneth H. Young | last post: by
3 posts views Thread by droesler | last post: by
11 posts views Thread by xenoix | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.