Hi Guys
I am having a problem with my javascript at the moment but it makes absolutely no sense why it is going wrong.
I have a form and am using some javascript to validate it; seems simple so far.
Here is the validation code:
[CODE]
function checkForm(thisform)
{
//Check q1
elementname = “q1”;
check = false;
for (x=0; x<5; x++){
valuetocheck = document.getElementsByName(elementname)[x];
if (valuetocheck.checked == true){
check = true;
continue;
}
}
if (check == false){
alert(“Please answer question 1”);
break;
}
}
Now the problem I am having is with that break; statement. When a user enters the page, they are shown a welcome message and a question of whether they would like to complete the survey. There are two links and if the user clicks no, they are navigated away from the page, if they click yes this javascript is activated through a hyperlink:
[CODE]<a href=”Javascript:void(0)” onclick=”toggleLayer()”>
which runs this code:
[CODE]function toggleLayer()
{
document.getElementById(“feedback”).style.display=”none”;
document.getElementById(“survey”).style.display=”block”;
}
which basically hides the welcome message and displays the hidden form.
If I include the break; statement in the code, this hyperlink doesn’t work; if I omit it, it does. Any ideas?