onchange HOW!

onchange event handler to display the customer contact information whe

Page 1 of 1

1 Replies - 1327 Views - Last Post: 07 July 2008 - 01:05 PM

#1 ourcupoftea  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 07-July 08

onchange HOW!

Post icon  Posted 07 July 2008 - 08:29 AM

Nothing I have found anywhere tells me how to do this! I get the onload and the onunload but the onchange completely confusses me

These are the instructions: Create an onload event handler that displays “Please take our Customer Service Survey” in an alert box.
Also include an onchange event handler to display the customer contact information when the user leaves the final text field. Complete the project with an onunload event handler that displays an alert dialog box containing the text, “We appreciate your opinions!” Save the file as surveyprompts.html. Be sure to publish to your web site. http://purdyhandyman.com/

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Survey</title>

<style type="text/css">
<!--

}
-->
</style>
<link href="/BasicPHM.css" rel="stylesheet" type="text/css" />

<script type="text/Javascript">
<!--
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
	if (val) { nm=val.name; if ((val=val.value)!="") {
	  if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
		if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
	  } else if (test!='R') { num = parseFloat(val);
		if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
		if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
		  min=test.substring(8,p); max=test.substring(p+1);
		  if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
	} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_popupMsg(msg) { //v1.0
  alert(msg);
}
//-->
</script>
</head>

<body onload="MM_popupMsg('Please take our Customer Service Survey');MM_popupMsg('Please take our Customer Service Survey')" onunload="MM_popupMsg('We appreciate your opinions!')">


<div id="container2"><img src="/Graphics/PHM6a.png" alt="Logo" width="900" height="135" longdesc="/Graphics/PHM6a.png" /></div>
<div id="navbar">
<ul>
<li><a></a></li>
<li><a href="index.html">Home</a></li>
<li><a href="Steve.html">Steve</a></li>
<li><a href="Keys.html">Keys</a></li>
<li><a href="Drums.html">Drums</a></li>
<li><a href="Cars.html">Cars</a></li>
<li><a href="Contact.html">Contact</a></li>
<li><a href="Survey.html">Survey</a></li>
</ul>
</div> 

  <div class="clearing"></div>
  <div id="outer_wrapper">

  <div id="wrapper">
	<div id="container"><form action="mailto:[email protected]" method="post" enctype="multipart/form-data" id="phm">
   <p>
	<label></label>
	</p>
   <p> </p>
   <p><span class="withlines">Feedback Form </span></p>
   <table width="524">
	<tr>
	  <td colspan="5" class="style2"><div class="style4">
		<div>Was  your service preformed in a timely manner? </div>
	  </div></td>
	</tr>
	<tr>
	  <td class="style4"><label> </label>
		  <div>
			<div>
			  <input name="RadioGroup1" type="radio" value="Excellent " checked="checked" />
			Excellent </div>
		  </div>	  </td>
	  <td class="style2"><div class="style4">
		  <div>
			<input type="radio" name="RadioGroup1" value="Good" />
			Good</div>
	  </div></td>
	  <td class="style2"><div class="style4">
		  <div>
			<input type="radio" name="RadioGroup1" value="Fair" />
			Fair</div>
	  </div></td>
	  <td class="style2"><div class="style4">
		  <div>
			<input type="radio" name="RadioGroup1" value="Poor" />
			Poor</div>
	  </div></td>
	  <td class="style2"><div class="style4">
		  <div>
			<input type="radio" name="RadioGroup1" value="Very poor" />
			Very poor</div>
	  </div></td>
	</tr>
	
	<tr>
	  <td colspan="5" class="style4"><p> </p>
	  <p> </p></td>
	</tr>
	<tr>
	  <td colspan="5" class="style4"><label> 
		</label><div>
		  <div>Were  our prices competitive with other handymen? </div>
		</div>	  </td>
	</tr>
  
		<tr>
	  <td class="style4"><label> </label>
		  <div>
			<div>
			  <input name="RadioGroup2" type="radio" value="Excellent " checked="checked" />
			Excellent </div>
		  </div>	   </td>
	  <td class="style2"><div class="style4">
		  <div>
			<input type="radio" name="RadioGroup2" value="Good" />
			Good</div>
	  </div></td>
	  <td class="style2"><div class="style4">
		  <div>
			<input type="radio" name="RadioGroup2" value="Fair" />
			Fair</div>
	  </div></td>
	  <td class="style2"><div class="style4">
		  <div>
			<input type="radio" name="RadioGroup2" value="Poor" />
			Poor</div>
	  </div></td>
	  <td class="style2"><div class="style4">
		  <div>
			<input type="radio" name="RadioGroup2" value="Very poor" />
			Very poor</div>
	  </div></td>
	</tr>
	<tr>
	  <td colspan="5" class="style4"><div>
		<p> </p>
		<p> </p>
	  </div></td>
	</tr>
	<tr>
	  <td colspan="5" class="style2"><div class="style4">
		<div>Are  you satisfied with the job that was done for you? </div>
	  </div></td>
	</tr>
		<tr>
	  <td class="style4"><label> </label>
		  <div>
			<div>
			  <input name="RadioGroup3" type="radio" value="Excellent " checked="checked" />
			Excellent </div>
		  </div>	   </td>
	  <td class="style2"><div class="style4">
		  <div>
			<input type="radio" name="RadioGroup3" value="Good" />
			Good</div>
	  </div></td>
	  <td class="style2"><div class="style4">
		  <div>
			<input type="radio" name="RadioGroup3" value="Fair" />
			Fair</div>
	  </div></td>
	  <td class="style2"><div class="style4">
		  <div>
			<input type="radio" name="RadioGroup3" value="Poor" />
			Poor</div>
	  </div></td>
	  <td class="style2"><div class="style4">
		  <div>
			<input type="radio" name="RadioGroup3" value="Very poor" />
			Very poor</div>
	  </div></td>
	</tr>
	<tr>
	  <td colspan="5" class="style2"><span class="style4">
		<label>		</label>
	  </span>
	  <p class="style4"> </p>
	  <p class="style4">  </p></td>
	</tr>
	<tr>
	  <td colspan="5" class="style4"><label> </label>
		  <div>
			<div>How  likely are you to recommend our services to others? </div>
		  </div>	  </td>
	</tr>
	   <tr>
	  <td class="style4"><label> </label>
		  <div>
			<div>
			  <input name="RadioGroup4" type="radio" value="Excellent " checked="checked" />
			Excellent </div>
		  </div>	   </td>
	  <td class="style2"><div class="style4">
		  <div>
			<input type="radio" name="RadioGroup4" value="Good" />
			Good</div>
	  </div></td>
	  <td class="style2"><div class="style4">
		  <div>
			<input type="radio" name="RadioGroup4" value="Fair" />
			Fair</div>
	  </div></td>
	  <td class="style2"><div class="style4">
		  <div>
			<input type="radio" name="RadioGroup4" value="Poor" />
			Poor</div>
	  </div></td>
	  <td class="style2"><div class="style4">
		  <div>
			<input type="radio" name="RadioGroup4" value="Very poor" />
			Very poor</div>
	  </div></td>
	</tr>
  </table>
  <p> </p>
  <table width="610" border="0" cellspacing="0" cellpadding="0">
	<tr>
	  <td>Full Name:
		<input name="Name" type="text" id="Name" />
	   </td>
	  <td>  E-mail:
	  <input name="Email" type="text" id="Email" onblur="MM_validateForm('textfield','','R','textfield2','','RisEmail');return document.MM_returnValue" size="40" /></td>
	</tr>
  </table>
  <p> </p>
  <p><span class="withlines">Comments</span></p>
  <p><br />
	<textarea name="comments" rows="12" cols="60"></textarea>
  </p>
  <p> </p>
   
	   <p> <input type="submit" value="Send Feedback" name="submit" />
		<label>
		<input type="reset" value="Reset" name="Reset" />
		</label>
		<input type="hidden" value="2" name="step" />
	   </p>
</form>

	  <div id="content">
		
		
	  </div>
	</div>
		
  
	<div id="footer">purdyhandyman</div>	
	<div class="clearing"></div>
  </div>
  
</div>


</body>
</html>


Any help would be great !!!

Pam

Is This A Good Question/Topic? 0
  • +

Replies To: onchange HOW!

#2 BetaWar  Icon User is online

  • #include "soul.h"
  • member icon

Reputation: 1490
  • View blog
  • Posts: 8,217
  • Joined: 07-September 06

Re: onchange HOW!

Posted 07 July 2008 - 01:05 PM

onchange for textareas and textboxes works the same way as onblur, when you click off the selected area it does the onchange function. onchange only (as far as I can tell) works without having to blur the selected field in selections like so:

<select onchange="alert(this.value)">
<option value="test">Test</option>
<option value="this">This</option>
<option value="Out">Out</option>
</select>


By final text field I am not sure if you are talking the textarea or the email text box. There is also an error in the MM_validateForm function, it is expecting an object on line 19, which it isn't getting.

Here is line 19:
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1