so i want to know how the html code produces the form displayed in the browser? any ideas guys?
HTML Code:
<head>
<title>Exam entry</title>
<script language="javascript" type="text/javascript">
function validateForm() {
var result = true;
var msg="";
if (document.ExamEntry.name.value=="") {
msg+="You must enter your Name. \n";
document.ExamEntry.name.focus();
document.getElementById('name').style.color="red";
result = false;
}
if (document.ExamEntry.subject.value=="") {
msg+="You must enter the Subject. \n";
document.ExamEntry.subject.focus();
document.getElementById('subject').style.color="red";
result = false;
}
if (document.ExamEntry.examinationnumber.value=="") {
msg+="You must enter the Examination Number. \n";
document.ExamEntry.examinationnumber.focus();
document.getElementById('examination number').style.color="red";
result = false;
}
if (msg=="") {
return result;
}
{
window.alert(msg)
return result;
}
}
</script>
</head>
<body>
<p>
<font face="Candara">
<font size="2">
<h1><u>Exam Entry Form</u></h1>
<fieldset>
<form name="ExamEntry" method="post" action="success.html">
<table width="50%" border="0">
<tr>
<td id="name">Name</td>
<td><input type="text" name="name" /></td>
</tr>
<tr>
<td id="subject">Subject</td>
<td><input type="text" name="subject" /></td>
</tr>
<tr>
<tr>
<td id="examination number">Examination Number</td>
<td><input type="text" name="examinationnumber" maxlength="4"
</tr>
<tr>
<script type="text/javascript">
function validateRadio(obj,correct){
var result = 0
for(var i=0; i<obj.length; i++){
if(obj[i].checked==true && obj[i].value==correct) result = 1
}
if(!result && obj.value == correct) result = 1
return result
}
</script>
<tr>
<td><input onclick="if(!validateRadio(this,3)) alert('You have selected GCSCE')" name="a" value="1" type="radio"> GCSE
</tr>
<tr>
<td><input onclick="if(!validateRadio(this,3)) alert('You have selected AS')" name="a" value="2" type="radio"> AS
</tr>
<tr>
<td><input onclick="if(!validateRadio(this,3)) alert('You have selected A2')" name="a" value="4" type="radio"> A2
</tr>
</tr>
<td><input type="submit" name="Submit" value="Submit" onclick="return validateForm();" /></td>
<td><input type="reset" name="Reset" value="Reset" /></td>
</tr>
</table>
</form>
</p></font></size></body>
Bookmarks