PDA

View Full Version : Describe how this HTML code produces the form displayed in the browser?



jacob27
March 10th, 2014, 08:01 PM
Describe how this HTML code below produces the form displayed in the browser? Any Ideas?
Thanks
Jacob
<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=”re d”; result = false;
}

if(msg==””){
return result;
}

{ alert(msg) return result;
}
}

</script>
</head>

<body>
<h1>Exam Entry Form</h1>
<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>
<td><input type=”submit” name=”Submit” value=”Submit” onclick=”return validateForm();” /></td>
<td><input type=”reset” name=”Reset” value=”Reset” /></td>
</tr>

</table>
</form>
</body>

jacob27
March 10th, 2014, 08:06 PM
Describe how the JavaScript function below performs the validation check? Any Ideas?
Thanks Jacob
<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=”re d”; result = false;
}

if(msg==””){
return result;
}

{ alert(msg) return result;
}
}

</script>
</head>

<body>
<h1>Exam Entry Form</h1>
<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>
<td><input type=”submit” name=”Submit” value=”Submit” onclick=”return validateForm();” /></td>
<td><input type=”reset” name=”Reset” value=”Reset” /></td>
</tr>

</table>
</form>
</body>

ofnuts
March 10th, 2014, 09:51 PM
Is this cheating on homework/exam?

ofnuts
March 10th, 2014, 09:53 PM
Is this cheating on homework/exam?

Elfy
March 10th, 2014, 09:54 PM
While we are happy to serve as a resource for hints and for asking questions when you get stuck and need a little help, the Ubuntu Forums is not a homework service. Please do not post your homework assignments expecting someone else to do it for you.

Closed.

When you need hints only - let me know and I will open it again.

bapoumba
March 10th, 2014, 09:56 PM
Sorry to post in a closed thread. The dup thread has been merged in.