Hi,
I am kind of a newbie to web development. I am trying to create a web form for a class I am teaching. The idea is to have the students fill in the webform and, when they click submit, it will validate the contents to make sure all the questions were answered.
I have most of it working except the piece whereby I display the list of fields they did not fill in.
To do this, I created a simple <DIV> in the HTML just above the form definition. The div is blank. Here’s the HTML for that…
[FONT=”Courier New”]<div id=”divErrors”></div>[/FONT]
The idea is that when the user clicks submit, I want to first clear out the contents of the div as follows:
[FONT=”Courier New”] document.divErrors.innerHTML=””;[/FONT]
and once I have done that, I test the contents of the fields and append them to the innterHTML as follows:
[FONT=”Courier New”] if(frmMain.name.value==””){
if(!llError){
document.divErrors.innerHTML = lcMsg;
llError = true;
}
document.divErrors.innerHTML += “<LI>Your name.</LI>”;
}
[/FONT]
Here’s my problem. When the code gets to document.divErrors it tells that the element has no properties.
I have googled this but I cannot seem to figure out why this is happening or how to fix it. The <DIV> is definitely within the body of the HTML.
I am developing in FireFox but this will have to run in IE as well.
Any assistance would be greatly appreciated.