Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Infinite Loop Script

Avatar of Richard Korts
Richard KortsFlag for United States of America asked on
JavaScript
8 Comments1 Solution508 ViewsLast Modified:
See code.

The Javascript function chk_values gets stuck in an infinite loop.

Note the alerts.

I've looked at this till I'm blue in the face and I can't see why it doesn't fall out the end of the loop.

I'm sure it's VERY simple, I just can't see it.

Thanks
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<title>Event Mark Registrants Paid</title>
<style type="text/css">
	.pt18 {font-size: 18pt; font-family: Arial}
	.pt14 {font-size: 14pt; font-family: Arial}	
	.pt12 {font-size: 12pt; font-family: Arial}
	.pt11 {font-size: 11pt; font-family: Arial}
	.pt10 {font-size: 10pt; font-family: Arial}
	.pt8  {font-size: 8pt; font-family: Arial}
	.pt9  {font-size: 9pt; font-family: Arial}	
	.pt7  {font-size: 7pt; font-family: Arial}
</style>	
<script language="JavaScript">	
<!--
	ac = "";
	pid = "";
			ar = "N";
			
			regname = "";
			
	function get_data() {
		if (document.st.evnt.options[0].selected) {
			alert("Please select an Event.");
			return false;
		}
		eid = document.st.evnt.value;
		document.st.action = "event_mark_paid.php?id=" + eid;	
		document.st.submit();
		return true;
	}	
	function isdigit(test) {
		if (test == "0" || test == "1" || test == "2" ||
	    	test == "3" || test == "4" || test == "5" ||
	    	test == "6" || test == "7" || test == "8" ||
	    	test == "9")
			return true;
		else {
			return false;
	     }
	}
// Function to determine if a field is numeric
	function isnumeric(field) {
		len = field.length;
		for (i = 0; i < len; i++)
			if (isdigit(field.charAt(i)) == false) {
				return false;
			}
		return true;
	}		

	function chk_values() {
		if (ac == "a") {
			window.location = "admin_menu.php";
			return false;
		}
		ne = document.st.elements.length;	
		alert("no elements = " + ne);
		for (i = 0; i < ne; i++) {
			if (document.st.elements[i].type == "text") {
				if (document.st.elements[i].value != "") {
					val = document.st.elements[i].value;
					if (! isnumeric(val)) {
						alert("One or more New Amt Paid values is not a number.");
						return false;
					}
				}
			}
		}	
		alert("Ready to go to update");			
		return true;
	}	

// -->
</script>		
</head>

<body>
<form method="POST" name="st" action="test.php" onsubmit="return chk_values();" >
		<input type="hidden" name="eid" value="2011-21">
<table width="900" cellpadding="0" cellspacing="0">

	<tr>
		<td colspan="3"><img src="images/admin_header.jpg"></td>
	</tr>
	<tr>
		<td><img src="images/vline_left.jpg" width="50" height="450"></td>
		<td valign="top"><table width="100%" cellpadding="0" cellspacing="0">
				<tr>
					<td><img src="images/spacer.gif" width="800" height="5"></td>
				</tr>

				<tr>
					<td bgcolor="#52021F"><img src="images/spacer.gif" width="800" height="2"></td>
				</tr>
				<tr>
					<td><img src="images/spacer.gif" width="800" height="5"></td>
				</tr>
				<tr>
					<td class="pt14" align="center"><font color="#52021F"><b>Event Registrants Paid</b></font></td>

				</tr>	
				<tr>
					<td><img src="images/spacer.gif" width="800" height="20"></td>
				</tr>	
				
				<tr>
					<td>
						<table width="100%" class="pt9">
							<tr>
								<td align="right" width="35%">Select Event:&nbsp;</td>

								<td><select name="evnt" size="1" class="pt8" onchange="get_data();">
									<option> - Select Event - </option>
																	<option value="2011-21" selected>Physician Group Consolidation - 06/09/2011</option>
										
								</select></td>
							</tr>	
								
							<tr>
								<td colspan="2"><img src="images/spacer.gif" width="50" height="20"></td>
							</tr>	
						</table>	
						<table width="100%" class="pt10">		
						<tr>

							<td colspan="6" class="pt12"><b>Event Registrants Paid for Event Physician Group Consolidation</b></td>
						</tr>		
																																																																																																										
							<tr>
								<td colspan="6"><img src="images/spacer.gif" width="50" height="20"></td>
							</tr>
							
						<tr>
							<td valign="top"><b>Name</b></td>
							<td align="center" valign="top"><b>Member</b></td>

							<td align="center" valign="top"><b>Amt Paid</b></td>
							<td valign="top"><b>New Amt Paid</b></td>
						</tr>	
										
							<tr>
								<td>M0201</td>
								<td align="center">N</td>
								<td align="center">$45</td>

								<td>$<input type="text" name="apaid0" class="pt8" size="5">
								</td>												
							</tr>
										
							<tr>
								<td>-- Select Non-Member --</td>
								<td align="center">N</td>
								<td align="center">$45</td>

								<td>$<input type="text" name="apaid1" class="pt8" size="5">
								</td>												
							</tr>
										
							<tr>
								<td>Claudia Alvidrez</td>
								<td align="center">Y</td>
								<td align="center">$25</td>

								<td>$<input type="text" name="apaid2" class="pt8" size="5">
								</td>												
							</tr>
										
							<tr>
								<td>David Korts</td>
								<td align="center">N</td>
								<td align="center">$60</td>

								<td>$<input type="text" name="apaid3" class="pt8" size="5">
								</td>												
							</tr>
										
							<tr>
								<td>Donald Trump</td>
								<td align="center">N</td>
								<td align="center">$250</td>

								<td>$<input type="text" name="apaid4" class="pt8" size="5">
								</td>												
							</tr>
							
						
					
							<tr>
								<td colspan="6"><img src="images/spacer.gif" width="50" height="20"></td>
							</tr>					
							<tr>
								<td colspan="6" align="center"><input type="submit" value="Update Paid" onMousedown="ac='u';" class="pt8"><img src="images/spacer.gif" width="100" height="5"><input type="submit" value="Admin Menu" onMousedown="ac='a';" class="pt8"></td>
							</tr>																																																																																																																																																										
						</table>

					</td>
				</tr>										
			</table>
		</td>					
		<td><img src="images/vline_right.jpg" width="50" height="450"></td>	
	</tr>
	<tr>
		<td><img src="images/ll_border.jpg"></td>
		<td><img src="images/vline_bot.jpg" width="800" height="50"></td>
		<td><img src="images/lr_border.jpg"></td>

	</tr>	
</form>	
</table>


</body>
</html>