Question : what javascript will loop through an array or evaluate a list for the following error checking javascript enbedded within a ColdFusion 9 form?

I have data returned from a query that outputs in an array named 'uarray' and a list named 'ulist'.

I have not succeeded in altering the following script to prompt the user with an error for the array or the list. It only works with a hard coded example that follows.

      if (document.updateForm.mtf_uic_id.value == 'N00160') {
              alert('Please enter a New UIC for this Associated MTF UIC.\n(An Associated MTF UIC must be unique.)');
             document.updateForm.mtf_uic_id.style.backgroundColor='yellow';
             document.updateForm.mtf_uic_id.focus();
             errorfound = true;
      }

The complete function follows:

function submitForm(){
            clearErrors();
            // alert("Submit Form was clicked");
            
      var errorfound = false;
            
      var uic = document.updateForm.mtf_uic_id.value
      var uic1 = uic.charAt(0)      

      if (document.updateForm.mtf_uic_id.value == 'N00160') {
              alert('Please enter a New UIC for this Associated MTF UIC.\n(An Associated MTF UIC must be unique.)');
             document.updateForm.mtf_uic_id.style.backgroundColor='yellow';
             document.updateForm.mtf_uic_id.focus();
             errorfound = true;
      }

      if(errorfound == false) {
      else {
            return false;
            }
      }

Thanks very much,
Mark

Answer : what javascript will loop through an array or evaluate a list for the following error checking javascript enbedded within a ColdFusion 9 form?

a last code using ulist and without the clearErrors function
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">

	var ulist = "N00160,N00161,N00162,N00163,N00165,N00166,N00167,N00168,N00169,N00183";

	function submitForm(){
		var uarray = ulist.split(",");
		var fields = document.updateForm.elements;
		for(var j=0;j<fields.length;j++) {
			for(var i=0;i<uarray.length;i++) {
				if ( fields[j].value == uarray[i] ) {
					alert("Please enter a New UIC for this Associated MTF UIC.\n(An Associated MTF UIC must be unique.)");
					fields[j].style.backgroundColor = "yellow";
					fields[j].focus();
					return false; // error !
				}
				else {
					fields[j].style.backgroundColor = "white";
				}
			}
		}
		return true; // no error
	}

</script>
</head>
<body onload="clearErrors();">
<form id="updateForm" name="updateForm" action="http://www.experts-exchange.com" onsubmit="return submitForm();">
	<input type="input" id="mtf_uic_id" name="mtf_uic_id" value="N00160" style="background-color:#F00" />
	<input type="input" id="mtf_vic_id" name="mtf_vic_id" value="N00165" style="background-color:#F00" />
	<input type="input" id="mtf_wic_id" name="mtf_wic_id" value="N00190" style="background-color:#F00" />
    <br />
    <input type="submit" value="submit" />
</form>
</body>
</html>
Random Solutions  
 
programming4us programming4us