All pastes #952557 Raw Edit

Mine

public text v1 · immutable
#952557 ·published 2008-03-22 09:44 UTC
rendered paste body
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en"><html><head>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <meta name="GENERATOR" content="Mozilla/4.75C-CCK-MCD {C-UDP; EBM-APPLE} (Macintosh; U; PPC) [Netscape]">
	<style type="text/css">
.style1 {
	text-align: center;
}
<title>Excersise 11</title>
</style>
</head><body text="#330066" bgcolor="#ffffff" link="#3300cc" vlink="#330066" alink="#33ff33">

<center>
<h2>
<font color="#1717ff"><font size="+3">Practical exercise eleven.</font></font></h2></center>

<center>
<h2>
<font color="#1717ff"><font size="+3">Simple if then else example.</font></font></h2></center>

<p><br><font size="+2">This script illustrates the use of a binary decision
control structure.</font>
<br><font face="Courier New,Courier"><font color="#230fff"><font size="+1">function
test(theparam)</font></font></font>
<br><font face="Courier New,Courier"><font color="#230fff"><font size="+1">&nbsp;&nbsp;&nbsp; {
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (theparam &gt;= 50)</font></font></font>
<br><font face="Courier New,Courier"><font color="#230fff"><font size="+1">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; {document.form1.Outputwindow.value
=" you got a pass"</font></font></font>
<font face="Courier New,Courier"><font color="#230fff"><font size="+1">}</font></font></font>
<br><font face="Courier New,Courier"><font color="#230fff"><font size="+1">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else</font></font></font>
<br><font face="Courier New,Courier"><font color="#230fff"><font size="+1">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; {</font></font></font>
<font face="Courier New,Courier"><font color="#230fff"><font size="+1"><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; alert("The
result was a fail","")</font></font></font><br><font face="Courier New,Courier"><font color="#230fff"><font size="+1">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; document.form1.Outputwindow.value
=" you need&nbsp; " + ( 50 -theparam)&nbsp; + <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; " more marks"</font></font></font>
<br><font face="Courier New,Courier"><font color="#230fff"><font size="+1">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }//
end of the decision</font></font></font>
<br><font face="Courier New,Courier"><font color="#230fff"><font size="+1">&nbsp;&nbsp;&nbsp; }//
end of the function</font></font></font>
</p><p><font size="+2">Q1. Copy and modify the script to produce a result of
"Credit " for marks over 75 and "pass" for marks between 50 and 75 inclusive.<br>
</font></p>
<p><font size="+2">result &lt; 50 --&gt;fail<br>
result &gt;= 50&nbsp; &amp;&nbsp; result &lt;=75&nbsp; --&gt; pass<br>
result &gt;75 credit<br>
<br>
</font>
</p>
<p><script>
<!-- Beginning of JavaScript 
function test(theparam)
{ if (theparam >= 50)
{document.form1.Outputwindow.value =" You got a Pass"
}
else
{
alert("The result was a fail","")
document.form1.Outputwindow.value =" You need  " + ( 50 -theparam)  + " more marks"
}
{ if (theparam >75 && <99)
{document.form1.Outputwindow.value =" You got a Credit"
}
}// end of the decision
}// end of the function
// - End of JavaScript - -->
</script>
</p><form name="form1">
	<div class="style1">
		<textarea name="Outputwindow" cols="60" style="height: 55px"></textarea>
<br><br>
		Type a test mark here:&nbsp;<input size="10" name="parameter_holder" type="text">
		<br>
		<br>
		Check the test mark to see if its a pass.&nbsp;<br>
		<br>
		<input type="button" value="What is the Result?" onclick="test(document.form1.parameter_holder.value)" name="Button" style="width: 131px">
<hr></div>
</form>
<br>&nbsp;
<br>&nbsp;
</body></html>