?
Solved

theForm.elements has no properties error help

Posted on 2006-05-03
5
Medium Priority
?
352 Views
Last Modified: 2008-01-16
Hi,

Ive been working on a validation javascript and some helpful folks here on experts have helped me out with it. For a test, the code works great as shown in the first sample below.

My orignal post was answered here.
http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_21832981.html

But now that Ive implemented the script in my web app which dynamically generates the output of the file and some parts of the javascript it doesnt seem to work and Im not sure why. I have the two code examples below. the first example is one that works and the second is the code that was was dynamically generated and doesnt work (the javascript on the post).

I did check in firefox javascript console and in the second sample that doesnt work below I get the error:
Error: theForm.elements["dispmax_" + groupName] has no properties dispmax.  Any help appreciated.



/***********************************************************/
<!-- WORKING EXAMPLE THAT WORKS PROPERLY                  -->
/***********************************************************/

<html>
<head>
</head>
<body>
<script language="javascript">
<!-- hide script from older browsers
function check_selected(theForm)
{
  if (isCheckMaxExceeded(theForm,"ITEM01")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"ITEM02")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"ITEM03")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"ITEM04")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"ITEM05")) {
      return false;
  }
  if (is_check_account_below(theForm, "50200") ||
      is_check_account_below(theForm, "50303") ||      
      is_check_account_below(theForm, "51474") ||
      is_check_account_below(theForm, "46010") ||      
      is_check_account_below(theForm, "51475") ||
      is_check_account_below(theForm, "55365") ||      
      is_check_account_below(theForm, "53187"))
     return false;

  // test
  msg = "All validations have succeeded. "
  msg = msg + "This is just a test page. There is no submission page."
  alert(msg);
  return (false);
  // just for test output
}
function isCheckMaxExceeded(theForm, groupName) {
    var max = parseInt(theForm.elements["dispmax_" + groupName].value);
    var min = 1;
    var count = 0;
    for (var i = 0; i < theForm.elements[groupName].length; i++) {
        if (theForm.elements[groupName][i].checked) {
            count++;
        }
    }
    if (count > max) {
        alert("You can only order a maximum of " + max + " screeners for item " + groupName + " Please uncheck some of your selections for this item.");    
        return true;
    } else {
        return false;
    }
}
function is_check_account_below (theForm, acct_name) {
     var min = 4;
     var count = 0;
     var input_collections = theForm.getElementsByTagName('input');
     var re = new RegExp("^" + acct_name + "\\|");
     
     for (var i = 0; i < input_collections.length; ++ i) {
          if (input_collections[i].type == 'checkbox' && re.test(input_collections[i].value) && input_collections[i].checked) {
               ++ count;
          }
     }
     
     if (count < min) {
          alert("You must order at least " + min + " screeners for account " + acct_name + ". Please check some of your selections for this account.");
          return true;
     } else {
          return false;
     }
}
-->
</script>
<script language="javascript">
<!-- adds checks item values in a delimited list to field ostr
  function getCheckedValues(frm){
    var str = '';
    var delimeter = ',';
    var counter = 0;
    for(var i=0;i<frm.elements.length;i++){
      if((frm.elements[i].type=="checkbox") && (frm.elements[i].checked)){
        if(counter==0){str += frm.elements[i].value;}
        else{str += delimeter + frm.elements[i].value;}
        counter++;  
      }
    }
    frm.ostr.value = str;
  }
  function checkCheckBoxes(frm,flag){
    for(var i=0;i<frm.elements.length;i++){
      if(frm.elements[i].type=="checkbox"){
        frm.elements[i].checked = !flag;
        frm.elements[i].click();
      }
    }
  }
-->
</script>
<form name="orderSubmit" method="post" action="" onsubmit="return check_selected(this)">
<input name="ostr" type="text" value="" size="200"><br>
1. a user cannot order more than the max value of an item. For example
   a user cannot check more than 5 of ITEM01 This is currently working.<br><br>
   
2. The user cannot check less than 4 items per account. In other words
   for each account, the user cannot have less than 4 items checked<br><br>
   
  <table cellpadding="2" cellspacing="1" bgcolor="#333333">
    <tr bgcolor="#eeeeee">
      <td><b>Accounts --&gt; </b></td>
      <td>&nbsp;</td>
<td><input name="acct50200" type="text" value="50200" size="10" maxlength="12" disabled></td>
<td><input name="acct50303" type="text" value="50303" size="10" maxlength="12" disabled></td>
<td><input name="acct51474" type="text" value="51474" size="10" maxlength="12" disabled></td>
<td><input name="acct46010" type="text" value="46010" size="10" maxlength="12" disabled></td>
<td><input name="acct51745" type="text" value="51745" size="10" maxlength="12" disabled></td>
<td><input name="acct55365" type="text" value="55365" size="10" maxlength="12" disabled></td>
<td><input name="acct53187" type="text" value="53187" size="10" maxlength="12" disabled></td>
    </tr>
    <tr bgcolor="#eeeeee">
      <td><b>Title Screeners </b></td>
      <td>max avail</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
    </tr>
 
<!-- begin group 1 -->
<tr bgcolor="#eeeeee">
 <td nowrap><b>1 ITEM01</b> ITEM WIDGET 01</td>
 <input name="maxITEM01" type="hidden" value="5">
 <td align=center><input class="drpdwn2" name="dispmax_ITEM01" type="text" value="5" size="2" maxlength="2" disabled></td>
<td align=center><input type="checkbox" name="ITEM01" value="50200|ITEM01" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM01" value="50303|ITEM01" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM01" value="51474|ITEM01" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM01" value="46010|ITEM01" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM01" value="51745|ITEM01" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM01" value="55365|ITEM01" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM01" value="53187|ITEM01" onclick="getCheckedValues(this.form)"></td>
</tr>
<!-- end group 1 -->
 
 
<!-- begin group 2 -->
<tr bgcolor="#eeeeee">
 <td nowrap><b>2 ITEM02</b> ITEM WIDGET 02</td>
 <input name="maxITEM02" type="hidden" value="6">
 <td align=center><input class="drpdwn2" name="dispmax_ITEM02" type="text" value="6" size="2" maxlength="2" disabled></td>
<td align=center><input type="checkbox" name="ITEM02" value="50200|ITEM02" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM02" value="50303|ITEM02" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM02" value="51474|ITEM02" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM02" value="46010|ITEM02" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM02" value="51745|ITEM02" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM02" value="55365|ITEM02" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM02" value="53187|ITEM02" onclick="getCheckedValues(this.form)"></td>
</tr>
<!-- end group 2 -->
 
 
<!-- begin group 3 -->
<tr bgcolor="#eeeeee">
 <td nowrap><b>3 ITEM03</b> ITEM WIDGET 03</td>
 <input name="maxITEM03" type="hidden" value="7">
 <td align=center><input class="drpdwn2" name="dispmax_ITEM03" type="text" value="7" size="2" maxlength="2" disabled></td>
<td align=center><input type="checkbox" name="ITEM03" value="50200|ITEM03" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM03" value="50303|ITEM03" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM03" value="51474|ITEM03" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM03" value="46010|ITEM03" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM03" value="51745|ITEM03" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM03" value="55365|ITEM03" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM03" value="53187|ITEM03" onclick="getCheckedValues(this.form)"></td>
</tr>
<!-- end group 3 -->

<!-- begin group 4 -->
<tr bgcolor="#eeeeee">
 <td nowrap><b>4 ITEM04</b> ITEM WIDGET 04</td>
 <input name="maxITEM04" type="hidden" value="3">
 <td align=center><input class="drpdwn2" name="dispmax_ITEM04" type="text" value="3" size="2" maxlength="2" disabled></td>
<td align=center><input type="checkbox" name="ITEM04" value="50200|ITEM04" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM04" value="50303|ITEM04" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM04" value="51474|ITEM04" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM04" value="46010|ITEM04" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM04" value="51745|ITEM04" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM04" value="55365|ITEM04" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM04" value="53187|ITEM04" onclick="getCheckedValues(this.form)"></td>
</tr>
<!-- end group 4 -->

<!-- begin group 5 -->
<tr bgcolor="#eeeeee">
 <td nowrap><b>5 ITEM05</b> ITEM WIDGET 05</td>
 <input name="maxITEM05" type="hidden" value="3">
 <td align=center><input class="drpdwn2" name="dispmax_ITEM05" type="text" value="3" size="2" maxlength="2" disabled></td>
<td align=center><input type="checkbox" name="ITEM05" value="50200|ITEM05" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM05" value="50303|ITEM05" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM05" value="51474|ITEM05" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM05" value="46010|ITEM05" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM05" value="51745|ITEM05" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM05" value="55365|ITEM05" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="ITEM05" value="53187|ITEM05" onclick="getCheckedValues(this.form)"></td>
</tr>
<!-- end group 5 -->
 
  </table>
  <br>
  <input type="submit" name="submit" value="Submit">
</form>
</body>
</html>



/***********************************************************/
<!-- DYNAMICALLY GENERATED PAGE BUT JAVASCRIPT DOES NOT WORK -->
/***********************************************************/
<html>
<head>
</head>
<body>
<script language="javascript">
<!-- hide script from older browsers
function check_selected(theForm)
{
  if (isCheckMaxExceeded(theForm,"VPDSCREENER01")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER02")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER03")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER04")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER05")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER06")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER07")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER08")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER09")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER10")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER11")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER12")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER13")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER14")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER15")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER16")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER17")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER18")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER19")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER20")) {
      return false;
  }
  if (is_check_account_below(theForm, "50200") ||
      is_check_account_below(theForm, "46010"))
     return false;
     
  // test
  msg = "All validations have succeeded. "
  msg = msg + "This is just a test page. There is no submission page."
  alert(msg);
  return (false);
  // just for test output
}
function isCheckMaxExceeded(theForm, groupName) {
    var max = parseInt(theForm.elements["dispmax_" + groupName].value);
    var min = 1;
    var count = 0;
    for (var i = 0; i < theForm.elements[groupName].length; i++) {
        if (theForm.elements[groupName][i].checked) {
            count++;
        }
    }
    if (count > max) {
        alert("You can only order a maximum of " + max + " screeners for item " + groupName + " Please uncheck some of your selections for this item.");    
        return true;
    } else {
        return false;
    }
}
function is_check_account_below (theForm, acct_name) {
     var min = 4;
     var count = 0;
     var input_collections = theForm.getElementsByTagName('input');
     var re = new RegExp("^" + acct_name + "\\|");
     
     for (var i = 0; i < input_collections.length; ++ i) {
          if (input_collections[i].type == 'checkbox' && re.test(input_collections[i].value) && input_collections[i].checked) {
               ++ count;
          }
     }
     
     if (count < min) {
          alert("You must order at least " + min + " screeners for account " + acct_name + ". Please check some of your selections for this account.");
          return true;
     } else {
          return false;
     }
}
-->
</script>
<script language="javascript">
  function getCheckedValues(frm){
    var str = '';
    var delimeter = ',';
    var counter = 0;
    for(var i=0;i<frm.elements.length;i++){
      if((frm.elements[i].type=="checkbox") && (frm.elements[i].checked)){
        if(counter==0){str += frm.elements[i].value;}
        else{str += delimeter + frm.elements[i].value;}
        counter++;  
      }
    }
    frm.ostr.value = str;
  }
  function checkCheckBoxes(frm,flag){
    for(var i=0;i<frm.elements.length;i++){
      if(frm.elements[i].type=="checkbox"){
        frm.elements[i].checked = !flag;
        frm.elements[i].click();
      }
    }
  }
</script>
<div align="left">
<table width=100% border=0 cellpadding="5" cellspacing="1" bgcolor="#333333">
 <tr bgcolor="#3366cc">
  <td height=20 align=center><font face="Arial" size="3" color="#FFFFFF"></font></td>
 </tr>
</table>
<br>
<br>
</div>
<form name="orderSubmit" method="post" action="no_screener_sales_order.html" onsubmit="return check_selected(this)">
<input name="ostr" type="hidden" value="">
<input name="sales-id" type="hidden" value="21">

  <table cellpadding="2" cellspacing="1" bgcolor="#333333">
    <tr bgcolor="#eeeeee">
      <td><b>Accounts --&gt; </b></td>
      <td>&nbsp;</td>
<td><input class="drpdwn2" name="acct50200" type="text" value="50200" size="10" maxlength="12" disabled></td>
<td><input class="drpdwn2" name="acct46010" type="text" value="46010" size="10" maxlength="12" disabled></td>
    </tr>
    <tr bgcolor="#eeeeee">
      <td><b>Title Screeners </b></td>
      <td>max avail</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
    </tr>
 
<!-- begin group 1 -->
<tr bgcolor="#eeeeee">
 <td nowrap><b>1 VPDSCREENER01</b> GENERIC SCREENER 01</td>
 <input name="maxVPDSCREENER01" type="hidden" value="5">
 <td align=center><input class="drpdwn2" name="dispmax_VPDSCREENER01" type="text" value="5" size="2" maxlength="2" disabled></td>
<td align=center><input type="checkbox" name="VPDSCREENER01" value="50200|VPDSCREENER01" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="VPDSCREENER01" value="46010|VPDSCREENER01" onclick="getCheckedValues(this.form)"></td>
</tr>
<!-- end group 1 -->
 
 
<!-- begin group 2 -->
<tr bgcolor="#eeeeee">
 <td nowrap><b>2 VPDSCREENER02</b> GENERIC SCREENER 02</td>
 <input name="maxVPDSCREENER02" type="hidden" value="6">
 <td align=center><input class="drpdwn2" name="dispmax_VPDSCREENER02" type="text" value="6" size="2" maxlength="2" disabled></td>
<td align=center><input type="checkbox" name="VPDSCREENER02" value="50200|VPDSCREENER02" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="VPDSCREENER02" value="46010|VPDSCREENER02" onclick="getCheckedValues(this.form)"></td>
</tr>
<!-- end group 2 -->
 
 
<!-- begin group 3 -->
<tr bgcolor="#eeeeee">
 <td nowrap><b>3 VPDSCREENER03</b> GENERIC SCREENER 03</td>
 <input name="maxVPDSCREENER03" type="hidden" value="7">
 <td align=center><input class="drpdwn2" name="dispmax_VPDSCREENER03" type="text" value="7" size="2" maxlength="2" disabled></td>
<td align=center><input type="checkbox" name="VPDSCREENER03" value="50200|VPDSCREENER03" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="VPDSCREENER03" value="46010|VPDSCREENER03" onclick="getCheckedValues(this.form)"></td>
</tr>
<!-- end group 3 -->
 
  </table>
  <br>
  <input type="submit" name="submit" value="Click Here To Submit Screener Order">
</form>
</body>
</html>
0
Comment
Question by:binovpd
  • 2
  • 2
5 Comments
 
LVL 7

Expert Comment

by:bubbledragon
ID: 16594303
You only three elements on the form and your function check_selected is checking 1 to 20. So, It can't found the element and return this error

theForm.elements["dispmax_" + groupName] has no properties dispmax.  
0
 
LVL 17

Expert Comment

by:gops1
ID: 16598914
Is check_selected function too gets generated dynamically. If so check the loop.
0
 

Author Comment

by:binovpd
ID: 16602189
bubble dragon is on the right track thanks. I adjusted my app so it out puts only the proper number of elements in the form. It works now, but now the piece that checks that user checks no les than 4 items per account seems to only work on the first account. AGain thanks to all for the help.

here is an example of the output:

<!-- Generated by Webspeed: http://www.webspeed.com/, http://www.possenet.org/ -->

<html>
<head>
</head>
<body>
<script language="javascript">
function check_selected(theForm)
{
  if (isCheckMaxExceeded(theForm,"VPDSCREENER01")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER02")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER03")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER04")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER05")) {
      return false;
  }
  if (isCheckMaxExceeded(theForm,"VPDSCREENER06")) {
      return false;
  }
  if (is_check_account_below(theForm, "50200") || is_check_account_below(theForm, "48378") || is_check_account_below(theForm, "51474"))
      return false;

  // test
  msg = "All validations have succeeded. "
  msg = msg + "This is just a test page. There is no submission page."
  alert(msg);
  return (false);
  // just for test output

}
function isCheckMaxExceeded(theForm, groupName) {
    var max = parseInt(theForm.elements["dispmax_" + groupName].value);
    var min = 1;
    var count = 0;
    for (var i = 0; i < theForm.elements[groupName].length; i++) {
        if (theForm.elements[groupName][i].checked) {
            count++;
        }
    }
    if (count > max) {
        alert("You can only order a maximum of " + max + " screeners for item " + groupName + " Please uncheck some of your selections for this item.");    
        return true;
    } else {
        return false;
    }
}
function is_check_account_below (theForm, acct_name) {
     var min = 4;
     var count = 0;
     var input_collections = theForm.getElementsByTagName('input');
     var re = new RegExp("^" + acct_name + "\|");
     for (var i = 0; i < input_collections.length; ++ i) {
          if (input_collections[i].type == 'checkbox' && re.test(input_collections[i].value) && input_collections[i].checked) {
               ++ count;
          }
     }
     if (count < min) {
          alert("You must order at least " + min + " screeners for account " + acct_name + ". Please check some of your selections for this account.");
          return true;
     } else {
          return false;
     }
}
</script>
<script language="javascript">
  function getCheckedValues(frm){
    var str = '';
    var delimeter = ',';
    var counter = 0;
    for(var i=0;i<frm.elements.length;i++){
      if((frm.elements[i].type=="checkbox") && (frm.elements[i].checked)){
        if(counter==0){str += frm.elements[i].value;}
        else{str += delimeter + frm.elements[i].value;}
        counter++;  
      }
    }
    frm.ostr.value = str;
  }
  function checkCheckBoxes(frm,flag){
    for(var i=0;i<frm.elements.length;i++){
      if(frm.elements[i].type=="checkbox"){
        frm.elements[i].checked = !flag;
        frm.elements[i].click();
      }
    }
  }
</script>
<div align="left">
<table width=100% border=0 cellpadding="5" cellspacing="1" bgcolor="#333333">
 <tr bgcolor="#3366cc">
  <td height=20 align=center><font face="Arial" size="3" color="#FFFFFF"><strong>Screener Order Request</strong></font></td>
 </tr>
</table>
<br>
<br>
</div>
<form name="orderSubmit" method="post" action="screener_sales_order.html" onsubmit="return check_selected(this)">
<input name="ostr" type="hidden" value="">
<input name="sales-id" type="hidden" value="21">
  <strong>Check the screener item you wish to order for each account. You cannot order more than the max number allowed for each screener.</strong><br><br>
  Your userid is <b>bino.</b>  Your Salesman number is <b>21</b>
  <table cellpadding="2" cellspacing="1" bgcolor="#333333">
    <tr bgcolor="#eeeeee">
      <td><b>Accounts --&gt; </b></td>
      <td>&nbsp;</td>
<td><input class="drpdwn2" name="acct50200" type="text" value="50200" size="10" maxlength="12" disabled></td>
<td><input class="drpdwn2" name="acct48378" type="text" value="48378" size="10" maxlength="12" disabled></td>
<td><input class="drpdwn2" name="acct51474" type="text" value="51474" size="10" maxlength="12" disabled></td>
    </tr>
    <tr bgcolor="#eeeeee">
      <td><b>Title Screeners </b></td>
      <td>max avail</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
    </tr>
 
<!-- begin group 1 -->
<tr bgcolor="#eeeeee">
 <td nowrap><b>1 VPDSCREENER01</b> GENERIC SCREENER 01</td>
 <input name="maxVPDSCREENER01" type="hidden" value="5">
 <td align=center><input class="drpdwn2" name="dispmax_VPDSCREENER01" type="text" value="5" size="2" maxlength="2" disabled></td>
<td align=center><input type="checkbox" name="VPDSCREENER01" value="50200|VPDSCREENER01" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="VPDSCREENER01" value="48378|VPDSCREENER01" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="VPDSCREENER01" value="51474|VPDSCREENER01" onclick="getCheckedValues(this.form)"></td>
</tr>
<!-- end group 1 -->
 
 
<!-- begin group 2 -->
<tr bgcolor="#eeeeee">
 <td nowrap><b>2 VPDSCREENER02</b> GENERIC SCREENER 02</td>
 <input name="maxVPDSCREENER02" type="hidden" value="6">
 <td align=center><input class="drpdwn2" name="dispmax_VPDSCREENER02" type="text" value="6" size="2" maxlength="2" disabled></td>
<td align=center><input type="checkbox" name="VPDSCREENER02" value="50200|VPDSCREENER02" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="VPDSCREENER02" value="48378|VPDSCREENER02" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="VPDSCREENER02" value="51474|VPDSCREENER02" onclick="getCheckedValues(this.form)"></td>
</tr>
<!-- end group 2 -->
 
 
<!-- begin group 3 -->
<tr bgcolor="#eeeeee">
 <td nowrap><b>3 VPDSCREENER03</b> GENERIC SCREENER 03</td>
 <input name="maxVPDSCREENER03" type="hidden" value="7">
 <td align=center><input class="drpdwn2" name="dispmax_VPDSCREENER03" type="text" value="7" size="2" maxlength="2" disabled></td>
<td align=center><input type="checkbox" name="VPDSCREENER03" value="50200|VPDSCREENER03" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="VPDSCREENER03" value="48378|VPDSCREENER03" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="VPDSCREENER03" value="51474|VPDSCREENER03" onclick="getCheckedValues(this.form)"></td>
</tr>
<!-- end group 3 -->
 
 
<!-- begin group 4 -->
<tr bgcolor="#eeeeee">
 <td nowrap><b>4 VPDSCREENER04</b> GENERIC SCREENER 04</td>
 <input name="maxVPDSCREENER04" type="hidden" value="1">
 <td align=center><input class="drpdwn2" name="dispmax_VPDSCREENER04" type="text" value="1" size="2" maxlength="2" disabled></td>
<td align=center><input type="checkbox" name="VPDSCREENER04" value="50200|VPDSCREENER04" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="VPDSCREENER04" value="48378|VPDSCREENER04" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="VPDSCREENER04" value="51474|VPDSCREENER04" onclick="getCheckedValues(this.form)"></td>
</tr>
<!-- end group 4 -->
 
 
<!-- begin group 5 -->
<tr bgcolor="#eeeeee">
 <td nowrap><b>5 VPDSCREENER05</b> GENERIC SCREENER 05</td>
 <input name="maxVPDSCREENER05" type="hidden" value="4">
 <td align=center><input class="drpdwn2" name="dispmax_VPDSCREENER05" type="text" value="4" size="2" maxlength="2" disabled></td>
<td align=center><input type="checkbox" name="VPDSCREENER05" value="50200|VPDSCREENER05" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="VPDSCREENER05" value="48378|VPDSCREENER05" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="VPDSCREENER05" value="51474|VPDSCREENER05" onclick="getCheckedValues(this.form)"></td>
</tr>
<!-- end group 5 -->
 
 
<!-- begin group 6 -->
<tr bgcolor="#eeeeee">
 <td nowrap><b>6 VPDSCREENER06</b> GENERIC SCREENER 06</td>
 <input name="maxVPDSCREENER06" type="hidden" value="2">
 <td align=center><input class="drpdwn2" name="dispmax_VPDSCREENER06" type="text" value="2" size="2" maxlength="2" disabled></td>
<td align=center><input type="checkbox" name="VPDSCREENER06" value="50200|VPDSCREENER06" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="VPDSCREENER06" value="48378|VPDSCREENER06" onclick="getCheckedValues(this.form)"></td>
<td align=center><input type="checkbox" name="VPDSCREENER06" value="51474|VPDSCREENER06" onclick="getCheckedValues(this.form)"></td>
</tr>
<!-- end group 6 -->
 
  </table>
  <br>
  <input type="submit" name="submit" value="Click Here To Submit Screener Order">
</form>
</body>
</html>
0
 
LVL 7

Accepted Solution

by:
bubbledragon earned 500 total points
ID: 16602832
I use indexof to check the string

function is_check_account_below (theForm, acct_name) {
     var min = 4;
     var count = 0;
     var input_collections = theForm.getElementsByTagName('input');
     var re = acct_name.toString() + "|";
     for (var i = 0; i < input_collections.length; ++ i) {
          if (input_collections[i].type == 'checkbox' && input_collections[i].checked && (input_collections[i].value.indexOf(re) == 0) )
            ++ count;
     }
     if (count < min) {
          alert("You must order at least " + min + " screeners for account " + acct_name + ". Please check some of your selections for this account.");
          return true;
     } else {
          return false;
     }
}
0
 

Author Comment

by:binovpd
ID: 16607153
Did the trick thanks Bubbledragon
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question